diff options
author | Thomas Lange <code@nerdmind.de> | 2016-01-14 23:05:53 +0100 |
---|---|---|
committer | Thomas Lange <code@nerdmind.de> | 2016-01-14 23:05:53 +0100 |
commit | 3631b1fd07ce46ec2e38402cda0cdcbceb1f38e5 (patch) | |
tree | 371a7d4659b6be7a2da9314d7ee3369197e3e161 | |
parent | 9369e89d8ce6f2582219970f333e4b0c9c792793 (diff) | |
download | snippets-3631b1fd07ce46ec2e38402cda0cdcbceb1f38e5.tar.gz snippets-3631b1fd07ce46ec2e38402cda0cdcbceb1f38e5.tar.xz snippets-3631b1fd07ce46ec2e38402cda0cdcbceb1f38e5.zip |
Option --lock-all-tables added
-rw-r--r-- | Bash/mysql-database-backup.sh | 12 |
1 files changed, 11 insertions, 1 deletions
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 <thomas@nerdmind.de>] # +#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%# +# # +# 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 |