Backup and restore
Back up the database and the configuration and keys in /etc/gadka. If file uploads are enabled, back up S3 storage as well.
What to back up
| Data | Location | Notes |
|---|---|---|
| Database | /var/lib/gadka/gadka.db (SQLite) or your PostgreSQL or MySQL server | Contains all conversations, accounts, and settings |
| Configuration and keys | /etc/gadka | Includes mfa-key and jwt-signing-key.pem |
| User files | S3 storage | Only needed if you enabled files |
You can leave /var/lib/gadka/nats out of the backup.
Back up a SQLite database
This command creates a consistent copy of the live database. You can keep the server running.
sudo gadka --config /etc/gadka/gadka.yaml admin backup --out /var/lib/gadka/gadka-$(date +%F-%H%M).dbAfter writing the backup, the server prints the path to the file.
backup written to /var/lib/gadka/gadka-2026-11-19-0200.dbChoose a new destination file each time. The command never overwrites an existing backup.
Encrypt the backup and transfer it to a separate machine. Once the transfer is complete, remove the backup file from /var/lib/gadka.
Back up a PostgreSQL or MySQL database
The gadka admin backup command supports SQLite only. For other databases, use their own tools, such as pg_dump or mysqldump.
Back up the configuration and keys
sudo tar -czf gadka-etc-$(date +%F).tar.gz -C /etc gadkaThe archive contains keys. Protect it as you would a password.
Schedule a daily backup
This example entry in root’s crontab (sudo crontab -e) runs daily at 02:00.
0 2 * * * /usr/local/bin/gadka --config /etc/gadka/gadka.yaml admin backup --out /var/lib/gadka/gadka-$(date +\%F).dbThis entry only creates the backup. Schedule separate tasks to move backups to another machine and remove old files.
Restore a SQLite database
- Stop the services.
sudo systemctl stop gadka-proxy gadka- Replace the database and remove the old database’s auxiliary files.
sudo install -o gadka -g gadka -m 0640 gadka-kopia.db /var/lib/gadka/gadka.db
sudo rm -f /var/lib/gadka/gadka.db-wal /var/lib/gadka/gadka.db-shm- Start the services.
sudo systemctl start gadka gadka-proxy- Run
gadka healthcheck && echo OK, then sign in to the app.
Restore on a new machine
- Run the Gadka installer on the new machine.
- Stop the services, restore
/etc/gadkafrom the archive, and restore the database. - Start the services.