🚑 critically fixed bash syntax in file + added feature of excluding directories from the backup listed in ".nobackup" file

main
Isabell Pflug 3 years ago
parent 7df5b74541
commit af957a3697

@ -0,0 +1,3 @@
/home/isabell/.cache/
/home/isabell/.steam/
/home/isabell/.xsession-errors

@ -1,14 +1,23 @@
#!/bin/bash
# variables
BACKUP_PATH="/media/isabell/Elements\ SE/isabell_tuxedo/"
# EXCLUDED_DIRS={}
BACKUP_PATH=/media/isabell/Elements\ SE/isabell_tuxedo/
NOBACKUP_FILE=.nobackup
# backup execution
if [[ -f $BACKUP_PATH ]] && echo "Starting rsync backup of home directory to $BACKUP_PATH"; then
#if [ "$EXCLUDED_DIRS" = "" ]; then
rsync -av --delete $HOME $BACKUP_PATH
#fi
if [[ -d "$BACKUP_PATH" ]] && echo "Starting rsync backup of home directory to $BACKUP_PATH"; then
if [[ -f "$NOBACKUP_FILE" ]] && echo "Found $NOBACKUP_FILE file, proceeding? (y/n)"; then
read PROCEEDING
if [[ "$PROCEEDING" == "y" ]]; then
rsync -av --delete --filter 'dir-merge,- $NOBACKUP_FILE' "$HOME/" "$BACKUP_PATH"
fi
else
echo "No $NOBACKUP_FILE found, proceeding to back-up entire home directory? (y/n)"
read PROCEEDING
if [[ "$PROCEEDING" == "y" ]]; then
rsync -av --delete "$HOME/" "$BACKUP_PATH"
fi
fi
else
echo "Device or location designated for the backup does not exist."
fi

Loading…
Cancel
Save