Generalise db remote backup script, add restore script

This commit is contained in:
Rohan Mitchell
2013-11-15 10:42:58 +11:00
parent 2ce687fc79
commit daee827af6
3 changed files with 16 additions and 5 deletions

7
script/backup.sh Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/bash
# Usage: script/backup.sh [ofn-staging1|ofn-staging2|ofn-prod]
set -e
ssh $1 "pg_dump -h localhost -U openfoodweb openfoodweb_production |gzip" > db/backup/$1-`date +%Y%m%d`.sql.gz

View File

@@ -1,5 +0,0 @@
#!/bin/bash
set -e
ssh ofn-prod "pg_dump -h localhost -U openfoodweb openfoodweb_production |gzip" > db/backup/ofn-prod-`date +%Y%m%d`.sql.gz

9
script/restore.sh Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/bash
# Usage: script/restore.sh [file.sql.gz]
set -e
echo "drop database open_food_network_dev" | psql -h localhost -U ofn open_food_network_test
echo "create database open_food_network_dev" | psql -h localhost -U ofn open_food_network_test
zcat $1 |psql -h localhost -U ofn open_food_network_dev