Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions backup_script.sh
Original file line number Diff line number Diff line change
@@ -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/./"
Expand Down Expand Up @@ -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 ---
Expand Down
2 changes: 1 addition & 1 deletion backup_script.sh.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4175a7e1000fc6ecf3d94f11758b9d5b5ed86e3a88c0e0b973212a79780d6a8d backup_script.sh
2ce03d52c44801851ab0d17e5f6bea8c21ab59511e54c1131fda0ddcdfa2af1d backup_script.sh