Skip to content
Snippets Groups Projects

feat: updated backup doc

Merged Rémi PAILHAREY requested to merge backup-doc into master
1 file
+ 8
14
Compare changes
  • Side-by-side
  • Inline
@@ -2,26 +2,20 @@
## Principles
In the docker-compose.yml, there is a service called "database-backup" whose only purpose is to run automatic backups of the database.
It is running a crontab that execute the backup.sh script every day at midnight.
The dump of the database are stored in folders name like this : "ecolyo-agent-YEAR-MONTH-DAY-HOUR-MINUTE-SECOND". Only the 14 last days are stored.
The location of the backup folder on the server is specified in the volumes of the "database-backup" service, in the docker-compose file.
Backups are scheduled automatically with the help of CronJobs on Openshift.
## Backup manually
To backup manually, run this command :
To backup manually, use `oc login` and `oc project` to authenticate to the correct namespace, then run this command :
```sh
docker exec -it ecolyo-agent_database-backup_1 sh /etc/cron.d/backup.sh
oc create job --from cronjob/mysql-dump-cronjob-hourly nom_du_job
```
## Restore manually
To restore a specific dump, run this command replacing YEAR etc.. by the date of the wanted backup :
```sh
docker exec -it ecolyo-agent_database-backup_1 sh /etc/cron.d/restore.sh ecolyo-agent-YEAR-MONTH-DAY-HOUR-MINUTE-SECOND
```
- Monter un pod du déploiement "database-restore"
- Rentrer dans le terminal de ce pod
- Aller dans le dossier des dumps horaires `cd /dump/hourly` ou journaliers `cd /dump/hourly` ou hebdomadaires `cd /dump/weekly`
- Décompresser le dump souhaité `gzip -d YYYY-MM-dd_hh:mm:ss.sql.gz`
- Restorer ce dump (remplacer seulement YYYY-MM-dd_hh:mm:ss.sql) `mysql -uroot -p$MYSQL_ROOT_PASSWORD -h$DATABASE_HOST $MYSQL_DATABASE < YYYY-MM-dd_hh:mm:ss.sql`
Loading