From 3631b1fd07ce46ec2e38402cda0cdcbceb1f38e5 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Thu, 14 Jan 2016 23:05:53 +0100 Subject: Option --lock-all-tables added --- Bash/mysql-database-backup.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Bash/mysql-database-backup.sh b/Bash/mysql-database-backup.sh index 241f283..a2df521 100644 --- a/Bash/mysql-database-backup.sh +++ b/Bash/mysql-database-backup.sh @@ -1,4 +1,13 @@ #!/bin/bash +#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%# +# MySQL database backup script [Thomas Lange ] # +#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%# +# # +# This database backup script loop through each database (except the excluded # +# databases in DATABASE_EXCLUDED) and creates a bzip2 compressed backup file. # +# # +#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%# + #=============================================================================== # Define database login credentials and excluded databases #=============================================================================== @@ -28,11 +37,12 @@ fi #=============================================================================== # Fetch all databases from local MySQL server #=============================================================================== -DATABASES=`mysql --user="${DATABASE_USERNAME}" --password="${DATABASE_PASSWORD}" --execute "SHOW DATABASES;" | grep -Ev "${DATABASE_EXCLUDED}"` +DATABASES=`mysql --user="${DATABASE_USERNAME}" --password="${DATABASE_PASSWORD}" --execute="SHOW DATABASES;" | grep -Ev "${DATABASE_EXCLUDED}"` #=============================================================================== # Loop through all databases and create compressed dump #=============================================================================== for database in ${DATABASES}; do + echo "[INFO] Creating compressed database backup for ${database}" mysqldump --lock-all-tables --user="${DATABASE_USERNAME}" --password="${DATABASE_PASSWORD}" "${database}" | bzip2 > $(printf "${DIRECTORY_FILE}" "${database}") done \ No newline at end of file -- cgit v1.2.3