summaryrefslogtreecommitdiffstats
path: root/Bash
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2019-11-15 08:42:28 +0100
committerThomas Lange <code@nerdmind.de>2019-11-15 08:47:47 +0100
commit32b8d78047e328dd9cd1e3b5b52a10cd972c2fa4 (patch)
treee90ec426cf1cb3f77bb0ad61b1fbf86a1f05ee99 /Bash
parent0ac1df78f2082a39d02beaf12db8e607106ea8f4 (diff)
downloadsnippets-32b8d78047e328dd9cd1e3b5b52a10cd972c2fa4.tar.gz
snippets-32b8d78047e328dd9cd1e3b5b52a10cd972c2fa4.tar.xz
snippets-32b8d78047e328dd9cd1e3b5b52a10cd972c2fa4.zip
mkdir DIRECTORY_ROOT if not exist
Diffstat (limited to 'Bash')
-rwxr-xr-xBash/mysql-database-backup.sh8
-rwxr-xr-xBash/virtualhosts-backup.sh8
2 files changed, 12 insertions, 4 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
diff --git a/Bash/virtualhosts-backup.sh b/Bash/virtualhosts-backup.sh
index ecdcb3b..eb2a9b7 100755
--- a/Bash/virtualhosts-backup.sh
+++ b/Bash/virtualhosts-backup.sh
@@ -47,7 +47,11 @@ DIRECTORY_FROM="/var/www/"
#===============================================================================
# Delete old backups in backup root directory
#===============================================================================
-find "${DIRECTORY_ROOT}"* -maxdepth 0 -type d -mtime +14 -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
@@ -84,4 +88,4 @@ for username in $(find ${DIRECTORY_FROM}* -maxdepth 0 -type d -exec basename {}
[ ! $ARGUMENT_QUIETMODE ] && echo "[INFO] Creating compressed backup for virtualhost $virtualhost [...]"
tar --create --bzip2 --file "$(printf "${DIRECTORY_FILE}" "${virtualhost}")" --directory "${DIRECTORY_FROM}${username}/" "${virtualhost}"
done
-done \ No newline at end of file
+done