summaryrefslogtreecommitdiffstats
path: root/Bash/mysql-database-backup.sh
diff options
context:
space:
mode:
Diffstat (limited to 'Bash/mysql-database-backup.sh')
-rwxr-xr-xBash/mysql-database-backup.sh14
1 files changed, 13 insertions, 1 deletions
diff --git a/Bash/mysql-database-backup.sh b/Bash/mysql-database-backup.sh
index 39b0a3d..746f215 100755
--- a/Bash/mysql-database-backup.sh
+++ b/Bash/mysql-database-backup.sh
@@ -6,9 +6,21 @@
# This database backup script goes through each database (except the excluded #
# databases in DATABASE_EXCLUDED) and creates a bzip2 compressed backup file. #
# #
+# OPTION [-q]: Enable quiet mode for use in crontab. #
+# #
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#
#===============================================================================
+# Parsing command-line arguments with the getopts shell builtin
+#===============================================================================
+while getopts :q option
+do
+ case $option in
+ q) ARGUMENT_QUIETMODE=true ;;
+ esac
+done
+
+#===============================================================================
# Define database login credentials and excluded databases
#===============================================================================
DATABASE_USERNAME="InsertYourUsernameHere"
@@ -43,6 +55,6 @@ DATABASES=$(mysql --user="${DATABASE_USERNAME}" --password="${DATABASE_PASSWORD}
# Loop through all database names and create compressed database backup
#===============================================================================
for database in ${DATABASES}; do
- echo "[INFO] Creating compressed backup for database ${database} [...]"
+ [ ! $ARGUMENT_QUIETMODE ] && echo "[INFO] Creating compressed backup for database ${database} [...]"
mysqldump --lock-all-tables --user="${DATABASE_USERNAME}" --password="${DATABASE_PASSWORD}" "${database}" | bzip2 > $(printf "${DIRECTORY_FILE}" "${database}")
done \ No newline at end of file