Added enter to confirm genrated command, and making shure that during system back up we don't back-up the back-up

master
Kynsight 2 weeks ago
parent 7599e37be8
commit 561f4ff265

@ -25,14 +25,25 @@ get_flag() {
VALID_FLAGS=( VALID_FLAGS=(
"source" "target" "dry-run" "verbose" "compress" "system" "source" "target" "dry-run" "verbose" "compress" "system"
"ssh-send" "ssh-receive" "link" "ntfs" "name" "exclude" "ssh-send" "ssh-receive" "link" "ntfs" "name" "exclude"
"progress"
) )
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# Default values and constants # Default values and constants
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
SYSTEM_EXCLUDES=( SYSTEM_EXCLUDES=(
"/dev/*" "/proc/*" "/sys/*" "/tmp/*" "/run/*" "/mnt/*" "/media/*" "/dev"
"swapfile" "lost+found" ".cache" "Downloads" ".ecryptfs" "/proc"
"/sys"
"/tmp"
"/run"
"/mnt"
"/media"
"/swapfile"
"/lost+found"
"/home/*/.cache"
"/home/*/Downloads"
"/home/*/.ecryptfs"
) )
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
@ -69,12 +80,14 @@ VERBOSE=false
COMPRESS=false COMPRESS=false
SYSTEM=false SYSTEM=false
NTFS=false NTFS=false
PROGRESS=false
get_flag "dry-run" && DRY_RUN=true get_flag "dry-run" && DRY_RUN=true
get_flag "verbose" && VERBOSE=true get_flag "verbose" && VERBOSE=true
get_flag "compress" && COMPRESS=true get_flag "compress" && COMPRESS=true
get_flag "system" && SYSTEM=true get_flag "system" && SYSTEM=true
get_flag "ntfs" && NTFS=true get_flag "ntfs" && NTFS=true
get_flag "progress" && PROGRESS=true
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# Required argument checks # Required argument checks
@ -96,6 +109,18 @@ else
TARGET_PATH="${TARGET[0]}" TARGET_PATH="${TARGET[0]}"
fi fi
# -----------------------------------------------------------------------------
# Prevent recursive backup of target inside source (Ask me how I Know)
# -----------------------------------------------------------------------------
if [[ "${SOURCE[0]}" == "/" || "${SOURCE[0]}" == /* ]]; then
# Resolve absolute target path
TARGET_REAL=$(realpath "$TARGET_PATH")
if [[ "$TARGET_REAL" == "${SOURCE[0]}"* ]]; then
EXCLUDES+=("$TARGET_REAL")
fi
fi
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# SSH configuration (push or pull) # SSH configuration (push or pull)
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
@ -152,8 +177,12 @@ if [[ "$NTFS" == false ]]; then
fi fi
[[ "$SYSTEM" == true ]] && CMD+=("-H") [[ "$SYSTEM" == true ]] && CMD+=("-H")
CMD+=("-P")
[[ "$PROGRESS" == true ]] && CMD+=("-P")
[[ "$PROGRESS" == false ]] && CMD+=("--partial")
CMD+=("--delete-excluded") CMD+=("--delete-excluded")
$VERBOSE && CMD+=("-v") $VERBOSE && CMD+=("-v")
$DRY_RUN && CMD+=("--dry-run") $DRY_RUN && CMD+=("--dry-run")
$COMPRESS && CMD+=("-z") $COMPRESS && CMD+=("-z")
@ -213,13 +242,14 @@ else
echo " └─ No Excludes Set" echo " └─ No Excludes Set"
fi fi
echo
echo "Command : ${CMD[*]}"
read -rp "If correct press neter to continue..."
echo echo
echo "┌──────────────────────────────────────────┐" echo "┌──────────────────────────────────────────┐"
echo "│ Executing Rsync Process │" echo "│ Executing Rsync Process │"
echo "└──────────────────────────────────────────┘" echo "└──────────────────────────────────────────┘"
echo "Command : ${CMD[*]}"
echo echo
# Uncomment to execute # Uncomment to execute
"${CMD[@]}" "${CMD[@]}"
echo echo

Loading…
Cancel
Save