check
}
-function restore_planetlab_db() {
- dumpfile=$1
- if [ -n "$dumpfile" ]; then
- [ -f "$dumpfile" ] && psql -a -U $PLC_DB_USER $PLC_DB_NAME <$dumpfile
- check
- fi
-}
-
# use a single date of this script invocation for the dump_*_db functions.
DATE=$(date +"%Y-%m-%d-%H-%M-%S")
checkpoint_planetlab_db $dumpfile
}
-function restore_drupal_db() {
- dumpfile=$1
- if [ -n "$dumpfile" ]; then
- [ -f "$dumpfile" ] && psql -a -U $PLC_DB_USER drupal <$1
- check
- fi
-}
-
function checkpoint_drupal_db() {
local dumpfile="$1"; shift
pg_dump -U $PLC_DB_USER drupal >$dumpfile
check
}
+function restore_planetlab_db() {
+ local dumpfile="$1"; shift
+ [[ -z "$dumpfile" ]] && { echo "Usage: $0 restore (planetlab5) <dumpfile>"; return 1; }
+ psql -U postgres -c "DROP DATABASE $PLC_DB_NAME"
+ createdb -U postgres --template=template0 --encoding=UNICODE --owner=$PLC_DB_USER $PLC_DB_NAME
+ psql -a -U $PLC_DB_USER $PLC_DB_NAME -f $dumpfile
+}
+
+function restore_drupal_db() {
+ local dumpfile="$1"; shift
+ [[ -z "$dumpfile" ]] && { echo "Usage: $0 restore (drupal) <dumpfile>"; return 1; }
+ psql -U postgres -c "DROP DATABASE drupal"
+ createdb -U postgres --template=template0 --encoding=UNICODE --owner=$PLC_DB_USER drupal
+ psql -a -U $PLC_DB_USER drupal -f $dumpfile
+}
+
# Clean up old backups
function clean_dump() {
local days="$1"; shift