diff --git a/docs/ecolyo-agent/technical/backup.md b/docs/ecolyo-agent/technical/backup.md index 4114bd8ca9378344a20db9b0577782cca90c75bd..4594103143e1df897023baeba48ea85d604de072 100644 --- a/docs/ecolyo-agent/technical/backup.md +++ b/docs/ecolyo-agent/technical/backup.md @@ -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`