Added ability to create a database dump at given position

This commit is contained in:
2020-02-21 11:37:47 +01:00
parent f3cd19e22e
commit ab91cc1ab9

View File

@@ -135,12 +135,29 @@ step_18() {
fi
}
step_20_info() { echo "Backup and restore a mysql database"; }
step_20_info() { echo "Backup (dump) a mysql database <DATABASE NAME> <TARGET DIR>"; }
step_20_alias() { ALIAS="backup"; }
step_20() {
echo "Dump the existing database with:"
echo " mysqldump --single-transaction nextcloud_db > NextcloudBackup_DB_\`date +\"%Y%m%d\"\`.sql"
echo
shift # step number not used
if [ -z $1 ] ; then
echoerr " [E] No database name provided"
return 1
fi
local dbName="$1"
local buTarget="$2"
if [ -z $2 ] ; then
echoerr " [W] No target directory provided. Using home of current user"
buTarget="~/"
fi
echo " [I] Dumping database $dbName to $buTarget"
exep "mysqldump --single-transaction $dbName > \"${buTarget}/${dbName}_backup_\`date +%Y%m%d-%H%M%S\`.sql\""
endReturn -o $? "Error creating $dbName backup"
}
step_22_info() { echo "Restore a mysql database"; }
step_22_alias() { ALIAS="restore"; }
step_22() {
echo "Restore with:"
echo " mysql -e \"DROP DATABASE nextcloud_db\""
echo " mysql -e \"CREATE DATABASE nextcloud_db\""
@@ -164,5 +181,5 @@ readDatabaseInfos() {
echo
}
VERSION_SEQREV=9
VERSION_SEQREV=10
. /usr/local/bin/sequencer.sh