Simple way to backup dev db running in Docker? #757
Unanswered
jay-cascade
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Okay, so it does work! I had not dropped the Database before executing... Still not sure this is the best way to work though? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am currently trying to create scripts to Backup my postgressql db, not sure this is the correct way to go?
backup_db.sh:
#!/bin/zsh
DIR="backups"
[ ! -d "$DIR" ] && mkdir -p "$DIR"
echo "Backing up database in ${DIR}..."
docker exec -t db pg_dumpall -c -U postgres > backups/dump_
date +%d-%m-%Y"_"%H_%M_%S
.sqlrestore_db.sh:
#!/bin/zsh
if [ $# -eq 0 ]
then
echo "Please supply path to SQL file you wish to restore"
exit 1
fi
echo "Restoring database $1..."
cat $1 | docker exec -i db psql -U postgres
Unfortunately this is not working for me though! How are others quickly restoring data for their docker dev environments?
Lots of errors about already existing relationships and problems copying, (small excerpt):
ERROR: duplicate key value violates unique constraint "UserNameIndex"
DETAIL: Key ("NormalizedUserName", "TenantId")=(ROOT.ADMIN, root) already exists.
CONTEXT: COPY Users, line 2
Beta Was this translation helpful? Give feedback.
All reactions