Backup and Restore scripts
This commit is contained in:
parent
ac6a8515b7
commit
c0b0ce8874
3 changed files with 24 additions and 0 deletions
7
bin/backupDB
Executable file
7
bin/backupDB
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
# CREATE DATABASE DUMP OF DB_FBF.
|
||||
docker exec django_fbf-db-1 /bin/bash -c "/usr/local/bin/pg_dump -U fbf -d db_fbf > /backup/fbf-backup.sql"
|
||||
|
||||
# cOPY AND COMPRESS DUMP FILE.
|
||||
docker exec django_fbf-db-1 /bin/bash -c "cd /backup && /bin/tar -czvf fbf-backup__$(date '+%Y-%m-%d').tar.gz fbf-backup.sql"
|
16
bin/restoreDB
Executable file
16
bin/restoreDB
Executable file
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
|
||||
# STOP WEB CONTAINER TO KILL ALL SESSIONS.
|
||||
docker stop django_fbf-web-1
|
||||
|
||||
# DROP THE DATABASE.
|
||||
docker exec -it django_fbf-db-1 psql -U fbf -d postgres -c "DROP DATABASE db_fbf;"
|
||||
|
||||
# CREATE THE DATABASE.
|
||||
docker exec -it django_fbf-db-1 psql -U fbf -d postgres -c "CREATE DATABASE db_fbf;"
|
||||
|
||||
# RESTORE THE DATABASE.
|
||||
docker exec -it django_fbf-db-1 /usr/local/bin/psql -U fbf -d db_fbf -f /backup/fbf-backup.sql
|
||||
|
||||
# START THE WEB CONTAINER.
|
||||
docker start django_fbf-web-1
|
Loading…
Add table
Add a link
Reference in a new issue