-
-
Notifications
You must be signed in to change notification settings - Fork 29
Backup the prod database
Nayor edited this page Dec 24, 2025
·
5 revisions
ssh compose0.exoscale.infra.camptocamp.org
source /opt/c2corg-docker/server-list.env
# go to the postgresql-backup composition
cd /opt/c2corg-docker/composition/production/postgresql-backup/
# enter the postgresql container
docker-compose exec postgresql bash
# pause the replication, create the dump and resume the replication
psql -U postgres -A0tc 'SELECT pg_xlog_replay_pause()'
pg_dump -U postgres -Fc --create c2corg > /var/backups/pgsql/c2corg_custom_backup.dump
psql -U postgres -A0tc 'SELECT pg_xlog_replay_resume()'
Note that you can also use the nightly backup script to backup all database in one pass, but this will overwrite the last night backup.
/usr/local/bin/pgsql-backup.sh
List existing backups:
ssh compose0.exoscale.infra.camptocamp.org "
cd /opt/c2corg-docker && source server-list.env && \
cd /opt/c2corg-docker/composition/production/postgresql-backup && source .env && \
docker-compose exec postgresql ls -la /var/backups/pgsql
"
Make a local copy:
BACKUP=pgsql_wednesday.tar
ssh compose0.exoscale.infra.camptocamp.org '
cd /opt/c2corg-docker && source server-list.env && \
cd /opt/c2corg-docker/composition/production/postgresql-backup && source .env
export POSTGRESQL_CONTAINER=`docker-compose ps -q postgresql`
docker -H $DOCKER_HOST exec $POSTGRESQL_CONTAINER cat /var/backups/pgsql/$BACKUP
' > ~/data/c2corgv6/backups/$BACKUP
ssh compose0.exoscale.infra.camptocamp.org
source /opt/c2corg-docker/server-list.env
cd /opt/c2corg-docker/composition/production/postgresql-backup/
# Replication is configured in docker-compose-initreplication.yml
docker volume rm c2corg_pgsql_replica
docker-compose -f docker-compose-initreplication.yml create && \
docker-compose -f docker-compose-initreplication.yml up && \
docker-compose up -d
This does not remove backup files (hosted out of docker) but only reset postgresql's streaming-replication.
β°οΈ Production UI β’ Production API β’ Prod π§ββοΈ
- π Home
- π Changelog
- π οΈ Dev tips
- πͺ Production Recipes
- π Deployment
- π¨βπ Useful informations
- β οΈ Legacy