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.sh8
1 files changed, 6 insertions, 2 deletions
diff --git a/Bash/mysql-database-backup.sh b/Bash/mysql-database-backup.sh
index 746f215..5d24a8a 100755
--- a/Bash/mysql-database-backup.sh
+++ b/Bash/mysql-database-backup.sh
@@ -37,7 +37,11 @@ DIRECTORY_FILE="${DIRECTORY_ROOT}${DIRECTORY_PATH}%s.sql.bz2"
#===============================================================================
# Delete old backups in backup root directory
#===============================================================================
-find "${DIRECTORY_ROOT}"* -maxdepth 0 -type d -mtime +30 -exec rm --recursive {} \;
+if [ -d "${DIRECTORY_ROOT}" ]; then
+ find "${DIRECTORY_ROOT}"* -maxdepth 0 -type d -mtime +90 -exec rm --recursive {} \;
+else
+ mkdir -p "${DIRECTORY_ROOT}"
+fi
#===============================================================================
# Create backup path directory if not exists
@@ -57,4 +61,4 @@ DATABASES=$(mysql --user="${DATABASE_USERNAME}" --password="${DATABASE_PASSWORD}
for database in ${DATABASES}; do
[ ! $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
+done