From 3b2a07f49306a6fcc1cb286350c89fa131a81319 Mon Sep 17 00:00:00 2001 From: vmaubert <github@vcmb.dev> Date: Tue, 11 Jun 2024 10:35:07 +0200 Subject: [PATCH] =?UTF-8?q?chore(backup):=20ajoute=20une=20commande=20pour?= =?UTF-8?q?=20r=C3=A9cup=C3=A9rer=20un=20backup=20sans=20les=20fichiers=20?= =?UTF-8?q?(#1234)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 3 ++- infra/roles/prod/templates/backup | 2 +- packages/api/.gitignore | 1 + packages/api/package.json | 4 ++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.dockerignore b/.dockerignore index 62333d9a8..1a9dfda3e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -12,6 +12,7 @@ infra/cd/.cargo_docker infra/cd/.cargo infra/cd/target packages/api/backups +packages/api/backup_without_files.backup packages/api/sources packages/api/files packages/api/api-cache @@ -20,4 +21,4 @@ packages/api/docs packages/ui/coverage packages/ui/stats.html packages/ui/dist -docs \ No newline at end of file +docs diff --git a/infra/roles/prod/templates/backup b/infra/roles/prod/templates/backup index abd3edf55..54e2f4d5f 100755 --- a/infra/roles/prod/templates/backup +++ b/infra/roles/prod/templates/backup @@ -16,7 +16,7 @@ docker exec camino_api_db vacuumlo camino docker exec camino_api_db pg_dump --clean --if-exists --format=d --no-owner --no-privileges --dbname=camino -f /dump docker exec camino_api_db chown -R "{{camino_user_uid}}:${USER_GROUP_ID}" /dump -docker exec camino_api_db pg_dump --clean --if-exists --no-owner --no-privileges -B --dbname=camino > /srv/backups/dump_without_files.sql +docker exec camino_api_db pg_dump --clean --if-exists --no-owner --no-privileges -B --dbname=camino --format c > /srv/backups/dump_without_files.backup # sauvegarde les fichiers rsync --delete -r /srv/www/camino/files/ /srv/backups/files diff --git a/packages/api/.gitignore b/packages/api/.gitignore index 0b57daf9d..aadffd090 100644 --- a/packages/api/.gitignore +++ b/packages/api/.gitignore @@ -8,6 +8,7 @@ node_modules /backups backup_without_files.sql +backup_without_files.backup /dist /coverage /api-cache diff --git a/packages/api/package.json b/packages/api/package.json index 17d9a9a67..96e33d805 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -11,9 +11,9 @@ "monthly": "node --loader ts-node/esm/transpile-only ./src/scripts/monthly.ts", "db:dump": "rm -rf ./backups/* && pg_dump --host=localhost --username=postgres --clean --if-exists --format=d --no-owner --no-privileges --dbname=camino --file=./backups/", "db:import": "pg_restore --host=localhost --username=postgres --clean --if-exists --no-owner --no-privileges --dbname=camino ./backups", - "db:import-without-files": "pg_restore --host=localhost --username=postgres --clean --if-exists --no-owner --no-privileges --dbname=camino ./backup_without_files.sql", + "db:import-without-files": "pg_restore --host=localhost --username=postgres --clean --if-exists --no-owner --no-privileges --dbname=camino < ./backup_without_files.backup", "db:prod-fetch": "rm -rf ./backups/* && ssh camino.beta.gouv.fr 'rm -f ~/backup.tgz && cd /srv/backups/dump/ && tar cvzf ~/backup.tgz .' && scp camino.beta.gouv.fr:~/backup.tgz backups/ && tar xvf backups/backup.tgz --directory ./backups", - "db:prod-fetch-without-files": "scp camino.beta.gouv.fr:/srv/backups/dump_without_files.sql ./backup_without_files.sql", + "db:prod-fetch-without-files": "scp camino.beta.gouv.fr:/srv/backups/dump_without_files.backup ./backup_without_files.backup", "db:recreate": "dropdb --host=localhost --username=postgres camino && createdb --host=localhost --username=postgres camino", "db:migrate": "node --loader ts-node/esm/transpile-only ./src/knex/migrate.ts", "db:add-migration": "NODE_OPTIONS='--loader ts-node/esm/transpile-only' knex migrate:make", -- GitLab