Skip to main content

Backups

What is backed up​

Every night at 3:30 (in your TZ) the server creates two encrypted files:

  • db-<date>.dump.enc: the database (pg_dump)
  • files-<date>.tar.gz.enc: all uploaded documents

Both are encrypted with AES-256 and your BACKUP_PASSPHRASE. 30 days are kept, the server deletes older ones. You can press Back up now in the admin area at any time.

They are in the folder /data/backups in the container, that is in the volume study-data (or under DATA_DIR/backups). A backup on the same server does not protect against a disk failure. Copy the folder to a second place regularly (another machine, cloud storage), for example with rsync or rclone:

# when using a host folder (DATA_DIR)
rclone copy /srv/study-manager/data/backups mystorage:study-manager-backups

With named volumes, you find the path with docker volume inspect study-manager_study-data.

Restoring​

Try this once on a test system before you need it.

  1. Start a new, empty installation (see Install) with the same .env (same BACKUP_PASSPHRASE, JWT_* and APP_SECRET).
  2. Copy the backup files to the server.
  3. Restore the database:
docker compose stop server
openssl enc -d -aes-256-cbc -pbkdf2 -pass env:BACKUP_PASSPHRASE -in db-<date>.dump.enc \
| docker compose exec -T db pg_restore --clean --if-exists --no-owner -U postgres -d postgres
  1. Restore the documents:
openssl enc -d -aes-256-cbc -pbkdf2 -pass env:BACKUP_PASSPHRASE -in files-<date>.tar.gz.enc \
| docker compose run --rm -T --no-deps --entrypoint sh server -c "tar xz -C /data/files"
  1. docker compose up -d and check that sign-in and documents are there.
Messages from pg_restore

With databases from the Supabase image, pg_restore often reports a few hundred errors ("errors ignored on restore"), for example about extensions and roles that already exist. They are expected and do not affect your data. What matters is that sign-in works and your courses and documents are there.

Without the BACKUP_PASSPHRASE the files cannot be decrypted. Keep it separate from the server.