Backup and restore
A backup you have never restored is a hypothesis. This page covers both halves, and the second half is the important one.
What a complete backup contains
| Component | Contains | Changes |
|---|---|---|
| MongoDB database | Employees, attendance, leave, projects, tasks, work reports, tracked time, settings, audit log | Constantly |
| Uploads volume | Screenshots, employee documents, chat attachments | Grows, rarely rewritten |
| .env file | Configuration and secrets | Rarely — but keep a copy somewhere safe |
Nightly script
#!/bin/sh
set -eu
STAMP=$(date +%F)
DEST=/backup
# database, live, no downtime needed
docker compose exec -T db \
mongodump --archive --gzip --db=employeedesk \
> "$DEST/edc-db-$STAMP.archive.gz"
# uploads, incremental
rsync -a --delete ./uploads/ "$DEST/uploads/"
# keep 14 daily database dumps
find "$DEST" -name 'edc-db-*.archive.gz' -mtime +14 -delete
Off-host or it does not count. A backup sitting on the same disk as the database survives an application bug and nothing else. Sync /backup to object storage or another machine, and check that the sync is still running once a quarter.
Restore
- Bring up a clean stackSame version tag as the backup was taken from. Restoring an older dump into a newer schema is a migration, not a restore.
- Restore the databaseDecompress the dump into the database container before the application container starts writing to it.
- Restore the uploads volumeCopy the uploads tree back into the mounted path, preserving ownership.
- Start the application and check health
GET /api/healthshould return 200 with the expected version. - Verify against known dataOpen an employee record, an attendance month and a screenshot from before the backup date. If a screenshot is missing, the uploads restore is incomplete.
# restore the database (--drop replaces existing collections)
docker compose exec -T db \
mongorestore --archive --gzip --drop < /backup/edc-db-2026-08-31.archive.gz
# restore uploads
rsync -a /backup/uploads/ ./uploads/
docker compose up -d
curl -fsS https://hr.yourcompany.com/api/health
Test it on a schedule
Restore into a scratch database once a quarter and open three records. It takes twenty minutes and it is the only way to know the backup works. Put it in the calendar of whoever owns the server, because it will not happen otherwise.
Related
Frequently asked
What is the minimum viable backup?
A mongodump archive plus the uploads directory. Those two together reconstruct the entire installation on a fresh host.
How often should we back up?
Nightly for the database is right for almost everyone. Uploads change slowly and can be synced incrementally rather than re-archived in full.
Do we need to stop the application to back up?
No. mongodump runs against a live database without downtime. On a replica set add --oplog for a point-in-time consistent archive; on a single node the archive is taken collection by collection, which is fine for this workload but worth knowing.
Something missing from the docs?
Tell us what you were looking for at support@employeedeskcrm.com and we will add it here.
- 7-day trial
- No credit card
- Cancel anytime