Last active
August 1, 2022 10:33
-
-
Save revolunet/338ba16ca29086a1bbcd86d7b6b0412e to your computer and use it in GitHub Desktop.
Kinto DB backup and restore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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