Repository navigation
Backup and Restore
Warracker stores data in two places, and a complete backup covers both:
- The PostgreSQL database — all warranties, users, claims, tags, and settings.
-
The uploads folder — all product photos, invoices, manuals, and other files (
/data/uploadsinside the container).
Back up a third thing too: your .env file. It holds the database passwords and SECRET_KEY. Store it somewhere safe and private — never in a public repository.
CSV export is a useful extra safety net for warranty data, but it does not include uploaded files, so it is not a substitute for a real backup.
- Backing up the database
- Backing up the uploads
- Automating backups
- Restoring
- Two things that trip people up
From the directory containing your compose file (replace warranty_db, warranty_user, and the container name with your own values from .env if they differ):
docker compose exec warrackerdb pg_dump -U warranty_user warranty_db > warracker-backup.sqlIf you use a bind mount (for example, ./uploads next to your compose file), copy that directory:
cp -r uploads uploads-backupIf you use a named volume (warracker_uploads), export it through a throwaway container:
docker run --rm -v warracker_uploads:/data -v "$(pwd)":/backup alpine \
tar -czf /backup/uploads-backup.tar.gz -C /data .Schedule both commands with cron (for example, nightly) and keep at least one copy off the machine — a second disk, another computer, or cloud storage. A backup you have never restored is a hope, not a backup: test the restore steps below on a spare setup at least once.
Filesystem or VM snapshots alone are not recommended as your only backup method — they are harder to restore selectively and easier to get subtly wrong.
-
Start a fresh stack (or stop the app container on the existing one):
docker compose stop warracker
-
Recreate the empty database and restore the dump into it:
docker compose exec warrackerdb psql -U warranty_user postgres \ -c "DROP DATABASE warranty_db;" -c "CREATE DATABASE warranty_db;" docker compose exec -T warrackerdb psql -U warranty_user warranty_db < warracker-backup.sql
-
Restore the uploads folder to its bind mount or volume, then restart the app:
docker compose up -d warracker
Database migrations run automatically on startup, so if the backup came from an older version, the database is brought up to date for you.
-
Log in and spot-check a few warranties, including one with documents attached.
-
SECRET_KEY: if you never set it in.env, the app generated one inside the container, and it is lost when the container is recreated. That only invalidates sessions — your data is unaffected — but users will have to log in again. SettingSECRET_KEYexplicitly in.envavoids this entirely. See Configuration. -
Mismatched names: the database name, user, and volume names in the restore commands must match your own
.envand compose file, not the examples above. If a command complains about a missing database or container, checkdocker compose psand your.envfirst.