What to back up
A DChat install keeps its state in three places. Back up all three.
| Where |
What it holds |
If you lose it |
| The SQL Server database |
Conversations and transcripts, visitors and contacts, agents and departments, settings, ratings and the audit log |
Everything. This is the one that matters most |
Web\App_Data\ |
Files attached to chats (uploads\chat), files you added as AI knowledge (knowledge), server logs, and the keys the server creates on first run |
Attachments are gone, agents sign in again, and credentials for connected channels must be entered again |
Web\appsettings.json and Web\dchat.lic |
Your connection string and settings, and the licence file if you bought Premium or Enterprise |
You re-enter the settings by hand and download the licence again from the client center |
The program files themselves do not need a backup. You can download the same version again. Keep a note of which version you run.
Step 1. Back up the database
A full backup once a day suits most support teams. Run this in SQL Server Management Studio or with sqlcmd, with your own database name and folder:
BACKUP DATABASE [DChat]
TO DISK = N'D:\Backup\DChat-full.bak'
WITH INIT, CHECKSUM;
RESTORE VERIFYONLY
FROM DISK = N'D:\Backup\DChat-full.bak'
WITH CHECKSUM;
CHECKSUM makes SQL Server check each page as it writes the backup. RESTORE VERIFYONLY confirms the file is complete and readable. Neither replaces a real restore test, which is step 4.
If losing a day of conversations is too much, set the database to the full recovery model and add transaction log backups during the day. Your database administrator will know the pattern; DChat needs nothing special.
Step 2. Schedule it
On SQL Server Standard or Enterprise, create a SQL Server Agent job or a maintenance plan that runs the backup every night.
SQL Server Express has no SQL Server Agent. Save the backup command in a file such as backup-dchat.sql, then create a task in Windows Task Scheduler that runs:
sqlcmd -S .\SQLEXPRESS -E -b -i D:\Backup\backup-dchat.sql
The -b switch makes the task report a failure when the backup fails, so Task Scheduler shows it. Run the task under an account that can sign in to SQL Server and write to the backup folder.
On Linux or Docker, run the same sqlcmd line from cron against your SQL Server instance.
Step 3. Copy the files, and move everything off the server
Copy Web\App_Data\, Web\appsettings.json and Web\dchat.lic on the same schedule. On Windows, robocopy does it in one line:
robocopy C:\inetpub\DChat\Web\App_Data D:\Backup\App_Data /MIR /R:2 /W:5
Then copy the backup folder to a second machine or to storage outside the server. A backup on the same disk as the database protects you from a mistake, not from a failed disk.
Two cautions. appsettings.json contains your database password and any AI provider keys, so store the copy where only administrators can read it. And in Docker, mount App_Data as a persistent volume; without one, the folder is lost every time the container is replaced.
Step 4. Test a restore
Do this once now, on a spare machine or a test server, so that the first time is not during an outage.
- Install SQL Server, of the same version as production or newer. A backup cannot be restored to an older version.
- Restore the database:
RESTORE DATABASE [DChat]
FROM DISK = N'D:\Backup\DChat-full.bak'
WITH RECOVERY;
- Unpack the same DChat version you run in production.
- Put back
appsettings.json, dchat.lic and the App_Data folder. Check that the connection string points to the restored database.
- Start the site and open
/api/health. Then sign in, open an old conversation, and download one attachment.
Write down how long it took. That number is your real recovery time, and it is the one to give anyone who asks.
A paid licence is tied to your deployment domain. A restore that serves the same hostname keeps working with the same licence file. Live chat itself needs no licence, so a test server on another name still runs with the Community features.
Before every upgrade
Take a fresh database backup and a copy of the three file locations before you install a new version. A new release can add tables and columns when it first starts, and the backup is your way back to the old version. Each release lists its upgrade steps in the READ_ME.txt file in the download, and the upgrade guide walks through them.
Keys, and running more than one server
On first run, the server creates a sign-in key and a key that protects stored channel credentials, and saves both under App_Data. That is why the folder belongs in the backup. If you run more than one instance behind a load balancer, or a container with no persistent volume, set Jwt:SecretKey and Channels:SecretKey in your configuration instead, so every instance uses the same keys.
How long to keep attachments and backups
By default DChat keeps chat attachments until you delete them. To remove old ones automatically, set Uploads:RetentionDays in appsettings.json. Remember that backups hold personal data too: when you set a retention period for conversations, set one for the backup files as well, and include backups in your answer to a data-erasure request. The GDPR page covers the export and erasure tools.
A short checklist
- Nightly full database backup with
CHECKSUM, verified.
- Nightly copy of
App_Data, appsettings.json and dchat.lic.
- Both copied off the server.
- A restore tested, and the time written down.
- A fresh backup before each upgrade.
Common questions
What do I need to back up on a DChat server?
Three things: the SQL Server database, the App_Data folder inside the Web folder, and two files in the Web folder, appsettings.json and your licence file if you have one. The database holds conversations, contacts, settings and the audit log. App_Data holds chat attachments, AI knowledge files and the keys created on first run.
Can I schedule backups on SQL Server Express?
Yes. SQL Server Express has no SQL Server Agent, so run the BACKUP DATABASE command with sqlcmd from Windows Task Scheduler. The backup command itself works the same way on every edition.
What happens if I restore the database but lose App_Data?
Conversations, contacts and settings come back with the database. Files that visitors and agents attached to chats are gone, agents have to sign in again, and credentials for connected channels have to be entered again. Set the keys in appsettings.json if you want them to survive without App_Data.
How often should I test a restore?
Test once when you set the backup up, and again after every upgrade or change of server. A restore to a spare machine or a second database name is enough. A backup that has never been restored is not yet a backup you can rely on.