Backup & Restore
Everything Trackarr knows lives in one PostgreSQL database: accounts, torrents, ratios, forum, settings. This guide covers backing it up, proving that the backup restores, and bringing it back on the same server or a new one.
It applies to the single-server install (docker-compose.prod.yml). In a replicated deployment, replication protects against a dead machine, not against a bad update or a deleted table: back up the primary there too.
A backup you never restored is a hope, not a backup
Do the three things on this page: make backups every night, copy them off the server, and test a restore from time to time.
What to Back Up
| What | Where it lives | How |
|---|---|---|
| Database | postgres_data volume | scripts/backup.sh |
.env | /opt/trackarr/.env | Encrypted copy made by scripts/backup.sh, or your password manager |
| Uploaded images | uploads_data volume | scripts/backup.sh --uploads |
Two values of .env cannot be regenerated without consequences:
| Variable | If you lose it |
|---|---|
IP_HASH_SECRET | Stored IP hashes no longer match anyone: IP bans and abuse history are void |
NUXT_SESSION_SECRET | Every user is logged out |
The others (DB_PASSWORD, PG_SUPERUSER_PASSWORD, REDIS_PASSWORD, TRACKER_INTERNAL_TOKEN) belong to one install and are generated again on a new server. Passkeys and login verifiers are in the database: they come back with it.
Making a Backup
cd /opt/trackarr
sudo ./scripts/backup.shThe script dumps the database through the postgres service of docker-compose.prod.yml, as the PostgreSQL administration role (the app's own role is not involved), compresses it and writes it to /var/backups/trackarr, a directory only root can read, outside the repository. Files older than 14 days are removed after each successful run. The site stays up during the dump.
/var/backups/trackarr/trackarr-db-20261201-033000.sql.gz.age the database
/var/backups/trackarr/trackarr-env-20261201-033000.age .env (encrypted backups only)Settings go in .env (or in the environment):
| Variable | Default | Purpose |
|---|---|---|
BACKUP_AGE_RECIPIENT | unset | age public key the backups are encrypted for. Unset: not encrypted |
BACKUP_DIR | /var/backups/trackarr | Where backups go. Must be outside /opt/trackarr |
BACKUP_RETENTION_DAYS | 14 | Days a backup is kept. 0 keeps everything |
BACKUP_UPLOADS | false | true also archives the uploads volume (same as --uploads) |
Encrypting Backups
A dump holds every account, passkey and login verifier. Unencrypted, whoever gets a copy of the file gets all of it, which is why the script warns on every run until a key is set, and why it only copies .env when it can encrypt it.
Backups are encrypted with age. Create the key pair on your own computer, not on the server:
age-keygen -o trackarr-backup.key
# prints: Public key: age1... (62 characters, yours)Keep trackarr-backup.key somewhere safe (password manager, offline copy): without it the backups cannot be read by anyone, you included. Then, on the server, install age and put your public key in /opt/trackarr/.env:
sudo apt install ageBACKUP_AGE_RECIPIENT=age1...the-public-key-printed-aboveThe server only holds the public key: it can write backups, not read them. An intruder who takes the server does not get your older backups with it.
Every Night
The installer offers it ("Back up the database every night?"). Run it again at any time to switch it on, it keeps your data and secrets:
cd /opt/trackarr
sudo ./scripts/install.shIt creates a systemd timer that runs scripts/backup.sh around 03:30:
systemctl list-timers trackarr-backup.timer # next run
journalctl -u trackarr-backup.service # what the last runs said
sudo systemctl start trackarr-backup.service # run one nowCopy Them Off the Server
A backup on the server dies with the server, and can be deleted by whoever breaks into it. Keep copies in at least one other place.
Pull them from another machine (the server needs no credentials for it):
rsync -a root@your-server:/var/backups/trackarr/ ~/trackarr-backups/Or push them to object storage after each backup, with rclone for example:
sudo systemctl edit trackarr-backup.service[Service]
ExecStartPost=/usr/bin/rclone copy /var/backups/trackarr remote:trackarr-backupsWhen the server pushes, give it credentials that can add files but not delete them, if your storage offers that. Only send encrypted backups off the server.
Test That a Backup Restores
cd /opt/trackarr
sudo ./scripts/restore.sh --verify /var/backups/trackarr/trackarr-db-20261201-033000.sql.gzThis is a real restore: the backup is loaded into a scratch database next to the live one, its tables, users and torrents are counted, and the scratch database is dropped. The live database is not touched, so run it as often as you like, once a month at least and after every upgrade.
An encrypted backup needs the private key for this, which is the point of testing: do it on your own computer, or copy the key to the server for the test and remove it afterwards.
sudo ./scripts/restore.sh --verify /var/backups/trackarr/trackarr-db-20261201-033000.sql.gz.age \
--identity /root/trackarr-backup.key
sudo shred -u /root/trackarr-backup.keyRestoring
On the Same Server
cd /opt/trackarr
sudo ./scripts/restore.sh /var/backups/trackarr/trackarr-db-20261201-033000.sql.gzThe script checks that the file can be read, asks you to type restore, dumps the current database first (in case the restore is the mistake), stops the app and the tracker, replaces the database, gives every table to the role the app connects with (DB_USER) and starts everything again. Add --identity FILE for an encrypted backup and --uploads ARCHIVE to put uploaded images back.
Everything written since the backup was made is lost. If the load fails, the app is left stopped on purpose: on an empty database, the first visitor to register becomes the administrator.
On a New Server
1. Install Trackarr
curl -fsSL https://raw.githubusercontent.com/florianjs/trackarr/main/scripts/install.sh -o install.sh
chmod +x install.sh
sudo ./install.shDo not register an account: the restore brings yours back. Go on to the next steps right away, since until the restore is done the first visitor to register becomes the administrator.
2. Put the two secrets back
Read them in the .env of the old server, or in its encrypted copy:
age -d -i trackarr-backup.key trackarr-env-20261201-033000.age | grep -E '^(IP_HASH_SECRET|NUXT_SESSION_SECRET)='Replace those two lines in /opt/trackarr/.env on the new server. Leave the rest of the new .env alone: DB_USER, DB_PASSWORD, PG_SUPERUSER_PASSWORD and REDIS_PASSWORD belong to the new install, and the old ones would lock the app out of its new database. The backup does not care which role owned the tables on the old server: the restore gives them to the DB_USER of the new one.
3. Copy the backup and the key over, then restore
scp trackarr-db-20261201-033000.sql.gz.age trackarr-backup.key root@new-server:/root/cd /opt/trackarr
sudo ./scripts/restore.sh /root/trackarr-db-20261201-033000.sql.gz.age --identity /root/trackarr-backup.key
sudo shred -u /root/trackarr-backup.keyThe restore starts every service again, which also applies the new secrets.
By Hand
The scripts only wrap these commands. The service is called postgres, every command needs the production compose file, and -T is required as soon as the output is piped:
cd /opt/trackarr
# Backup (write the file outside /opt/trackarr)
docker compose -f docker-compose.prod.yml exec -T postgres \
sh -c 'PGPASSWORD="$POSTGRES_PASSWORD" pg_dump --no-owner --no-privileges -U "$POSTGRES_USER" "$POSTGRES_DB"' \
| gzip > /var/backups/trackarr/manual.sql.gz
# Restore
docker compose -f docker-compose.prod.yml stop app tracker
docker compose -f docker-compose.prod.yml exec -T postgres sh -c \
'PGPASSWORD="$POSTGRES_PASSWORD" psql -U "$POSTGRES_USER" -d postgres \
-c "DROP DATABASE \"$POSTGRES_DB\" WITH (FORCE)" -c "CREATE DATABASE \"$POSTGRES_DB\""'
gunzip -c /var/backups/trackarr/manual.sql.gz \
| docker compose -f docker-compose.prod.yml exec -T postgres sh -c \
'PGPASSWORD="$POSTGRES_PASSWORD" psql -q -1 -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" -d "$POSTGRES_DB"'
# The superuser loaded the dump and owns the tables: give them to the app's
# role (on an install that never ran this script, it also does the role split)
sudo ./scripts/db-split-role.sh
docker compose -f docker-compose.prod.yml up -dThe single quotes matter: $POSTGRES_PASSWORD is read inside the database container, from its own environment. Never put the password itself on a command line (PGPASSWORD=secret docker ..., -e PGPASSWORD=secret): every user of the server can read the command lines of running programs.
Changing Domains
If you're migrating to a new domain (e.g., old-tracker.com → new-tracker.com):
1. Update DNS records
Create A records for your new domain pointing to your server's IP:
| Name | Record Type | Value |
|---|---|---|
new-tracker.com | A | Your VPS IP |
announce.new-tracker.com | A | Your VPS IP |
monitoring.new-tracker.com | A | Your VPS IP |
2. Update .env
cd /opt/trackarr
sudo nano .envDOMAIN=new-tracker.com
TRACKER_DOMAIN=announce.new-tracker.com
MONITORING_DOMAIN=monitoring.new-tracker.com
TRACKER_HTTP_URL=https://announce.new-tracker.com/announce3. Apply
sudo docker compose -f docker-compose.prod.yml up -dCaddy obtains the Let's Encrypt certificates for the new names by itself. There is no need to delete its data volume: that only throws away the certificates you may still want and counts against Let's Encrypt's rate limits.
WARNING
Changing the announce URL invalidates the .torrent files users already downloaded: they need to download them again, or edit the tracker URL in their client. Keep the old announce name pointing to the server for a while if you can.