From 0f147a5518addaa6eba39bb4864d940d4570da16 Mon Sep 17 00:00:00 2001 From: dinger1986 Date: Thu, 11 May 2023 19:54:07 +0100 Subject: [PATCH] Update backup.sh --- backup.sh | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/backup.sh b/backup.sh index d96fe8c4..a2e56762 100755 --- a/backup.sh +++ b/backup.sh @@ -18,6 +18,20 @@ if [[ $* == *--schedule* ]]; then crontab -l 2>/dev/null echo "0 0 * * * /rmm/backup.sh --auto" ) | crontab - + + if [ ! -d /rmmbackups/daily ]; then + sudo mkdir /rmmbackups/daily + fi + + if [ ! -d /rmmbackups/weekly ]; then + sudo mkdir /rmmbackups/weekly + fi + + if [ ! -d /rmmbackups/monthly ]; then + sudo mkdir /rmmbackups/monthly + fi + sudo chown -R ${USER}:${USER} /rmmbackups + printf >&2 "${GREEN}Backups setup to run at midnight and rotate.${NC}\n" exit 0 fi @@ -80,21 +94,6 @@ cp /rmm/api/tacticalrmm/tacticalrmm/local_settings.py ${tmp_dir}/rmm/ if [[ $* == *--auto* ]]; then - if [ ! -d /rmmbackups/daily ]; then - sudo mkdir /rmmbackups/daily - fi - - if [ ! -d /rmmbackups/weekly ]; then - sudo mkdir /rmmbackups/weekly - fi - - if [ ! -d /rmmbackups/monthly ]; then - sudo mkdir /rmmbackups/monthly - fi - - sudo chown -R ${USER}:${USER} /rmmbackups - - month_day=$(date +"%d") week_day=$(date +"%u")