Skip to content
Snippets Groups Projects
Commit b1cb22c7 authored by Rémi PAILHAREY's avatar Rémi PAILHAREY :fork_knife_plate:
Browse files

feat: updated backup doc

parent a4666a2a
No related branches found
No related tags found
1 merge request!37feat: updated backup doc
......@@ -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`
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment