Backup and restore¶
📋 Introduction¶
Data required to fully backup and restore a R2Devops system are the following:
- Configuration file:
.env
- Databases:
- PostgreSQL database of Jobs service
- PostgreSQL database of Kratos service
- Files data:
- Files stored in the Minio service
- File storing data about certificate for Traefik service
All these data can be easily backup and restored using 2 scripts from the installation git repository:
backup.sh
restore.sh
💽 Backup¶
To backup the system, go to your installation git repository and run the following command:
./backup.sh
The script will create a backups
directory and create a backup archive inside it prefixed with the date (backup_r2-$DATE
)
Regular backup
You can use a cron job to perform regular backups. Here is a cron job that launch a backup every day at 2am:
0 2 * * * /r2devops/backup.sh
crontab -e
. Check more information about cron jobs here. 🛳️ Restore¶
To restore a backup from scratch on a new system, follow this process:
- Be sure that your new system is compliant with requirements
- Copy the backup file on your new server
- Setup your environment
export REPOSITORY_TOKEN="REPLACE_ME" export REGISTRY_TOKEN="REPLACE_ME"
- Clone the installation repository
git clone https://r2devops:${REPOSITORY_TOKEN}@gitlab.com/r2devops/self-hosted.git r2devops cd r2devops
- If the IP address of your server changed from your previous installation, update your DNS records. See section 2 of domain configuration
- Login to R2Devops registry
echo $REGISTRY_TOKEN | docker login --username r2devops --password-stdin https://registry.gitlab.com/v2/r2devops
- Launch the restore script
./restore.sh <path_to_your_backup_file>
Any errors during the restore process ?
Did you encounter a problem during the restore process ? See the troubleshooting section.
Last update: February 15, 2023