Backups
Everything Trail records, plus your sites and goals, is in one SQLite file (TRAIL_DB). Back up that file and you have backed up Trail.
Online snapshot
sqlite3 .backup takes a consistent copy while Trail keeps running. Run it from cron on the host:
0 3 * * * sqlite3 /var/lib/trail/trail.db ".backup /backups/trail-$(date +\%F).db"Inside a crontab % must be written as \%.
The Docker image is distroless and has no shell or sqlite3. Back up from the host by mounting the volume into a throwaway container:
docker run --rm -v trail-data:/data -v /backups:/backups alpine \
sh -c 'apk add -q sqlite && sqlite3 /data/trail.db ".backup /backups/trail-$(date +%F).db"'Cold copy
When Trail is stopped, a plain cp of the .db file is a complete backup. While it runs, use .backup above instead: a copy of the file alone can miss recent writes that are still in the -wal file next to it.
Restore
- Stop Trail.
- Replace the file at
TRAIL_DBwith the backup, and delete any-waland-shmfiles beside it. - Start Trail.
Moving to a new server is the same: copy the file over and point TRAIL_DB at it.
What a backup does not hold
The private-mode daily key and the sessions of private visitors live only in memory. After a restart or a restore, a private visitor who comes back the same day is counted as new.
Next
- Keep the file safe across versions: Upgrades.
- Everything else is set in Configuration.