Backups and Restore
Protect your station's data.
A complete backup has three parts: the database, your .env file, and your Media Library uploads. Without ENCRYPTION_KEY, stored API keys in a restored database cannot be read.
These commands read passwords from .env, which is loaded into your shell first.
MongoDB with Docker
Back up:
set -a; . ./.env; set +a
docker compose exec -T mongo mongodump --username auvyra --password "$MONGO_ROOT_PASSWORD" --authenticationDatabase admin --db auvyra --archive --gzip > auvyra-backup.gzRestore:
set -a; . ./.env; set +a
docker compose exec -T mongo mongorestore --username auvyra --password "$MONGO_ROOT_PASSWORD" --authenticationDatabase admin --drop --archive --gzip < auvyra-backup.gz--drop replaces existing collections with the backup's contents.
PostgreSQL with Docker
Back up:
docker compose -f docker-compose.postgres.yml exec -T postgres pg_dump -U auvyra --clean --if-exists auvyra | gzip > auvyra-backup.sql.gzRestore:
gunzip -c auvyra-backup.sql.gz | docker compose -f docker-compose.postgres.yml exec -T postgres psql -U auvyra -d auvyra--clean makes the restore replace existing tables.
MySQL with Docker
Back up:
docker compose -f docker-compose.mysql.yml exec -T mysql sh -c 'exec mysqldump --user=auvyra --password="$MYSQL_PASSWORD" --no-tablespaces --single-transaction --set-gtid-purged=OFF auvyra' | gzip > auvyra-backup.sql.gzRestore:
gunzip -c auvyra-backup.sql.gz | docker compose -f docker-compose.mysql.yml exec -T mysql sh -c 'exec mysql --user=auvyra --password="$MYSQL_PASSWORD" auvyra'MariaDB with Docker
Back up:
docker compose -f docker-compose.mariadb.yml exec -T mariadb sh -c 'exec mariadb-dump --user=auvyra --password="$MARIADB_PASSWORD" --single-transaction auvyra' | gzip > auvyra-backup.sql.gzRestore:
gunzip -c auvyra-backup.sql.gz | docker compose -f docker-compose.mariadb.yml exec -T mariadb sh -c 'exec mariadb --user=auvyra --password="$MARIADB_PASSWORD" auvyra'SQLite with Docker
Your database and uploads share one volume. Stop Auvyra first, so the copy is complete, then copy the whole folder:
docker compose -f docker-compose.sqlite.yml stop web
docker compose -f docker-compose.sqlite.yml cp web:/data ./auvyra-backup
docker compose -f docker-compose.sqlite.yml start webTo restore, stop Auvyra and copy the folder back:
docker compose -f docker-compose.sqlite.yml stop web
docker compose -f docker-compose.sqlite.yml cp ./auvyra-backup/. web:/data
docker compose -f docker-compose.sqlite.yml start webMedia Library uploads with Docker
Uploads live in a Docker volume, and this copies them to a file in the current folder:
docker compose cp web:/data/uploads ./uploads-backupTo restore them:
docker compose cp ./uploads-backup/. web:/data/uploadsManual installations
Use mongodump and mongorestore, or pg_dump and psql, with your DATABASE_URL, or your hosted provider's backup feature.
Good habits
- Store backups away from the server they protect
- Keep
.envsomewhere secure and separate from database backups - Test a restore before you need one