Backups
This page is about backups of the database on the server. It requires you to have access to the server and already been connected to the ssh terminal.
To create backups manually and restore a backup, you'll need to have access to the server. To do so, create a SSH key if you don't have one yet, and send the public key to an admin to add it on the server.
Then, you can connect to the server with:
ssh <username>@nantral-platform.fr
Ask an admin for the <username>
of the server's user session.
🔄 Automatic Backups​
- Backups are run:
- each time you push an update to the server (via the deploy_server workflow)
- every week on Monday at 05:00 AM
- every day at 05:00 AM during September
- once a month, a notification is sent to discord to show backups still work
- Backups are stored on our S3 bucket on OVH.
- When a new backup is created, a cleanup is run to keep only the last 20 backups.
You can find and download the backups on the OVH platform, in Public Cloud > Object Storage > Backups.
Create backups manually
- Log into the server:
ssh <username>@nantral-platform.fr
- CD into the development directory:
cd nantralPlatform/deployment
- Create a backup of the database:
docker exec deployment_database_1 pg_dump -U <db_username> <db_name> > backup.sql
You can find
<db_username>
and<db_name>
in thebackend.env
file. A file namedbackup.sql
will then be created in thedeployment
directory. - Exit from the server:
exit
- Copy the backup file from the server to your local computer:
scp <username>@nantral-platform.fr:~/nantralPlatform/deployment/dump.sql ./dump.sql
💾 Restore a backup​
- Download the backup on your local computer.
- Copy the backup file from your local computer to the server:
scp backup.sql.gz <username>@nantral-platform.fr:~/nantralPlatform/deployment/backup.sql.gz
- Log into the server:
ssh <username>@nantral-platform.fr
- CD into the deployment directory:
cd nantralPlatform/deployment
- Unzip the backup file:
gunzip backup.sql.gz
- Copy the backup from the server to the Postgres docker container:
sudo docker cp backup.sql deployment_database_1:backup.sql
- Open the container's shell:
sudo docker exec -it deployment_database_1 bin/sh
- Replace the current database with the backup:
psql -U <db_username> <db_name> < backup.sql
You can find
<db_username>
and<db_name>
in thebackend.env
file. - In your browser, check on the website that the data has been restored correctly ✅
- Delete the backup.sql file in the container:
rm backup.sql
- Exit the container:
exit
- Delete the backup.sql file in the server:
rm backup.sql
- Exit the server:
exit