mysql - adding sanity check for backup target
This commit is contained in:
@@ -302,12 +302,14 @@ step_50() {
|
|||||||
fi
|
fi
|
||||||
local dbName="$1"
|
local dbName="$1"
|
||||||
local buTarget="$2"
|
local buTarget="$2"
|
||||||
if [ -z $2 ] ; then
|
if [ -z "$2" ] ; then
|
||||||
echoerr " [W] No target directory provided. Using home of current user"
|
echoerr " [W] No target directory provided. Using home of current user"
|
||||||
buTarget="~"
|
buTarget="$HOME"
|
||||||
|
elif [ ! -e "$2" ]; then
|
||||||
|
endReturn -o 1 -f "$2 does not exist"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo " [I] Dumping database $dbName to $(realpath $buTarget)"
|
echo " [I] Dumping database $dbName to $buTarget"
|
||||||
exep "mysqldump --single-transaction $dbName > \"$(realpath $buTarget)/${dbName}_backup_$(date +%Y%m%d-%H%M%S).sql\""
|
exep "mysqldump --single-transaction $dbName > \"$(realpath $buTarget)/${dbName}_backup_$(date +%Y%m%d-%H%M%S).sql\""
|
||||||
endReturn -o $? "Error creating $dbName backup"
|
endReturn -o $? "Error creating $dbName backup"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user