diff --git a/.dockerignore b/.dockerignore index 62333d9a8fec5a4e4b9d77b9cfc6ee1a7a0b6596..1a9dfda3e4c29cc496a8ff1b558df9468f5d869a 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 abd3edf55e2be78d28959e1eababf55c899e7aa8..54e2f4d5f9c65fb389bb4ebb61dc6b642f32d8fb 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 0b57daf9d1531e2f7120abb3d1bd75fea8b30446..aadffd090216c48534be2f6565c4d1c6220168c5 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 17d9a9a67b0f6f6452671dc92893c20f99545a70..96e33d805d5bc05e8186fcc442dc16ad5c770920 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",