diff --git a/backup_script.sh b/backup_script.sh index ac91700..d069ef5 100644 --- a/backup_script.sh +++ b/backup_script.sh @@ -1,5 +1,5 @@ #!/bin/bash -# ===================== v0.35 - 2025.08.21 ======================== +# ===================== v0.36 - 2025.08.29 ======================== # # Example backup.conf: # BACKUP_DIRS="/home/user/test/./ /var/www/./" @@ -59,10 +59,12 @@ else C_CYAN='' fi -# Check if the script is being run as root -if (( EUID != 0 )); then - echo "❌ This script must be run as root or with sudo." >&2 - exit 1 +# Re-run the script with sudo if not already root +if [[ $EUID -ne 0 ]]; then + echo -e "${C_BOLD}${C_YELLOW}This script requires root privileges to function correctly.${C_RESET}" + echo -e "${C_YELLOW}Attempting to re-run with sudo. You may be prompted for your password.${C_RESET}" + echo "----------------------------------------------------------------" + exec sudo "$0" "$@" fi # --- Determine script's location to load the config file --- diff --git a/backup_script.sh.sha256 b/backup_script.sh.sha256 index bc40865..6aeefe4 100644 --- a/backup_script.sh.sha256 +++ b/backup_script.sh.sha256 @@ -1 +1 @@ -4175a7e1000fc6ecf3d94f11758b9d5b5ed86e3a88c0e0b973212a79780d6a8d backup_script.sh +2ce03d52c44801851ab0d17e5f6bea8c21ab59511e54c1131fda0ddcdfa2af1d backup_script.sh