New exep function which handels pipes and redirects properly
rework mayan backup and restore steps
This commit is contained in:
@@ -150,15 +150,25 @@ user = mayan"
|
||||
step_20_info() { echo "Backup postgres database to media folder"; }
|
||||
step_20_alias() { ALIAS=backupdb; }
|
||||
step_20() {
|
||||
echo "Backup with standard user / database: mayan / mayan"
|
||||
exe pg_dump -h 127.0.0.1 -U mayan -c mayan -W > ${toolMediaFolder}/`date +%Y-%m-%d"_"%H-%M-%S`.sql
|
||||
local LASTYEAR=$(($(date +%Y)-1))
|
||||
if [ ! -s ~/.pgpass ] ; then
|
||||
echo "[INFO] For unattended backup please define ~/.pgpass containing credentials for user mayan"
|
||||
fi
|
||||
echo "Backup custom pg format with standard user / database: mayan / mayan"
|
||||
exep "pg_dump -h 127.0.0.1 -U mayan -Fc mayan | bzip2 -c > ${toolDbBackupFolder}/`date +%Y-%m-%d\"_\"%H-%M-%S`.backup.bz2"
|
||||
exe rm -f ${toolDbBackupFolder}/${LASTYEAR}*
|
||||
}
|
||||
toolDbBackupFolder=${toolMediaFolder}/backupdb
|
||||
|
||||
|
||||
step_22_info() { echo "Postgres database restore"; }
|
||||
step_22() {
|
||||
echo "1. Create a empty postgres database first (step 4)"
|
||||
echo "2. psql -h <host> -U <database user> -d <database name> -W -f <sql dump file>"
|
||||
echo " e.g. psql -h 127.0.0.1 -U mayan -d mayan -W -f 2018-06-07_18-10-56.sql"
|
||||
echo "or"
|
||||
echo "3. Custom postgres format dump restore:"
|
||||
echo " pg_restore -h localhost -p 5432 -U mayan -d new_db -v \"10.70.0.61.backup\""
|
||||
}
|
||||
|
||||
# Read postgres database information dbname/user/pass if empty
|
||||
|
Reference in New Issue
Block a user