Skip to content

Instantly share code, notes, and snippets.

@revolunet
Last active August 1, 2022 10:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save revolunet/338ba16ca29086a1bbcd86d7b6b0412e to your computer and use it in GitHub Desktop.
Save revolunet/338ba16ca29086a1bbcd86d7b6b0412e to your computer and use it in GitHub Desktop.
Kinto DB backup and restore
# backup some Kinto tables from remote database and restore in another one
# ⚠️ piping from docker/docker-compose is a bad idea
## get the dump
ssh HOST '{
cd /home/user/app;
PG_ID=`sudo docker-compose ps -q db`;
sudo docker exec $PG_ID pg_dump --clean --if-exists --quote-all-identifiers -t objects -t metadata -t timestamps -t access_control_entries -t user_principals -U postgres --format=custom postgres -f /backup.dump;
sudo docker cp $PG_ID:/backup.dump .
}'
## récupère le dump
scp HOST:/home/user/app/backup.dump .
## restore
docker-compose exec -T db pg_restore --clean --no-acl --no-owner --dbname test_kinto_db -v -U test_db_user < ./backup.dump
## If you restore on a fresh DB, be sure to include basic kinto stuff : https://raw.githubusercontent.com/Kinto/kinto/master/kinto/core/storage/postgresql/schema.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment