diff --git a/backup.sh b/backup.sh index c6c6ea9a..d96fe8c4 100755 --- a/backup.sh +++ b/backup.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -SCRIPT_VERSION="22" +SCRIPT_VERSION="23" GREEN='\033[0;32m' YELLOW='\033[1;33m' @@ -8,6 +8,11 @@ BLUE='\033[0;34m' RED='\033[0;31m' NC='\033[0m' +if [ $EUID -eq 0 ]; then + echo -ne "\033[0;31mDo NOT run this script as root. Exiting.\e[0m\n" + exit 1 +fi + if [[ $* == *--schedule* ]]; then ( crontab -l 2>/dev/null @@ -17,11 +22,6 @@ if [[ $* == *--schedule* ]]; then exit 0 fi -if [ $EUID -eq 0 ]; then - echo -ne "\033[0;31mDo NOT run this script as root. Exiting.\e[0m\n" - exit 1 -fi - if [ ! -d /rmmbackups ]; then sudo mkdir /rmmbackups sudo chown ${USER}:${USER} /rmmbackups @@ -82,18 +82,18 @@ if [[ $* == *--auto* ]]; then if [ ! -d /rmmbackups/daily ]; then sudo mkdir /rmmbackups/daily - sudo chown ${USER}:${USER} /rmmbackups/daily fi if [ ! -d /rmmbackups/weekly ]; then sudo mkdir /rmmbackups/weekly - sudo chown ${USER}:${USER} /rmmbackups/weekly fi if [ ! -d /rmmbackups/monthly ]; then sudo mkdir /rmmbackups/monthly - sudo chown ${USER}:${USER} /rmmbackups/monthly fi + + sudo chown -R ${USER}:${USER} /rmmbackups + month_day=$(date +"%d") week_day=$(date +"%u")