# Backup

## 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.

## Backup manually

To backup manually, run this command :

```sh
docker exec -it ecolyo-agent_database-backup_1 sh /etc/cron.d/backup.sh
```

## 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
```