跳转至

Data Backup and Recovery

Beatsight requires backing up three key components to ensure the system can be fully restored when needed. Below are detailed instructions for each part.

  1. Postgres Database

    Stores the system's structured data, such as project configurations, user information, and activity logs.

  2. Beatsight-Data Volume

    Contains uploaded files, cached data, and other system-generated files.

  3. Configuration Files

    Located in the runtime directory, these include system settings and service configurations. You can back up config files at any time. It is recommended to create a backup before making any configuration changes to allow for easy rollback if needed.

Postgres and beatsight-data must be backed up after stopping the services to prevent inconsistencies that might lead to errors. The specific steps are as follows:

Stop the services:

cd /opt/beatsight/beatsight-docker-1.3.0-ce
./dc stop web celery beat

Back up the database

docker exec -t beatsight-postgres pg_dumpall -c -U postgres > beatsight-db_`date +%Y-%m-%d"_"%H_%M_%S`.sql

If you need a smaller backup file, you can compress it using gzip:

docker exec -t beatsight-postgres pg_dumpall -c -U postgres | gzip > beatsight-db_`date +%Y-%m-%d"_"%H_%M_%S`.sql.gz

Back up Beatsight-data volume

docker run --rm -v beatsight-data:/data -v "$PWD/backups:/backups" beatsight/beatsight:v1.3.0-ce sudo tar -czvf /backups/beatsight-data_`date +%Y-%m-%d"_"%H_%M_%S`.tar.gz /data

After the backup is complete, you can find the corresponding compressed data package in the backups directory.


Restore Database and Data Volumes

You can execute the following commands to restore the data:

Restore the database:

cat beatsight-db.sql | docker exec -i beatsight-postgres psql -U postgres

Restore the data volume:

docker run --rm -v beatsight-data:/data -v "$PWD/backups:/backups" beatsight/beatsight:v1.3.0-ce sudo tar xzf /backups/beatsight-data.tar.gz -C /data

After restoring the data, restart the services to verify everything is functioning correctly:

./start.sh

Log in to the system and confirm the data integrity.