mysql - adding sanity check for backup target

This commit is contained in:
2022-02-17 08:42:50 +01:00
parent cec9739372
commit bc706fb121

View File

@@ -302,12 +302,14 @@ step_50() {
fi
local dbName="$1"
local buTarget="$2"
if [ -z $2 ] ; then
if [ -z "$2" ] ; then
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
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\""
endReturn -o $? "Error creating $dbName backup"
}