Skip to content

Backups

There are two components that need to be backed up:

  1. The postgresql database
  2. The data directory

To get started enter the directory where your docker-compose.yml file is stored:

Terminal window
cd ~/crossonic-server

And make sure that the db container is running (the crossonic-server can run aswell):

Terminal window
sudo docker compose up -d db

To backup the database create a database dump:

Terminal window
sudo docker compose exec db pg_dumpall --clean --if-exists --username=crossonic | gzip > db_backup.sql.gz

The database backup will be available at ./db_backup.sql.gz.

To backup the data directory, simply create a .tar.gz archive of the directory:

Terminal window
sudo tar -czf data_backup.tar.gz ./data

Your backup will be available at ./data_backup.tar.gz

To restore a backup first follow the installation guide but do not create any users and make sure you specify the same encryption key in your config that was used when the backup was created.

Next enter the directory of your docker-compose.yml file and make sure that your db_backup.sql.gz and data_backup.tar.gz files are available in the same directory.

To restore the backup execute these commands:

Terminal window
sudo docker compose down
sudo rm -rf ./postgres ./data
sudo docker compose pull
sudo docker compose up -d db
sleep 10
gunzip --stdout ./db_backup.sql.gz | sudo docker compose exec -iT db psql --dbname=postgres --username=crossonic
sudo tar -xzf ./data_backup.tar.gz
sudo docker compose up -d