diff --git a/duplicity-backup.conf.example b/duplicity-backup.conf.example index 04d8f09..73c173e 100644 --- a/duplicity-backup.conf.example +++ b/duplicity-backup.conf.example @@ -136,7 +136,7 @@ DEST="s3+http://foobar-backup-bucket/backup-folder/" # ) # # Simpler example with one location: -INCLIST=( "/home/foobar_user_name/Documents/" ) +# INCLIST=( "/home/foobar_user_name/Documents/" ) # EXCLUDE LIST OF DIRECTORIES # Even though I am being specific about what I want to include, @@ -151,7 +151,31 @@ INCLIST=( "/home/foobar_user_name/Documents/" ) # "/**.AppleDouble" \ # ) # Simpler example with one location. Adapt it to your needs. -EXCLIST=( "/home/foobar_user_name/Documents/foobar-to-exclude" ) +# EXCLIST=( "/home/foobar_user_name/Documents/foobar-to-exclude" ) + +# INCLUDE GLOBBING FILELIST +# Instead of using the INCLIST/EXCLIST variable you can also define a special +# (text-)file where each line in the filelist will be interpreted as +# a globbing pattern. By using the '+' or '-' sign at the beginning of each line +# you are able to specify if the folder should be included or excluded. +# +# +# Example: +# + /dir/foo +# - /dir/foob* +# + /dir/* +# +# From the duplicity manual: +# Lines starting with "+" are interpreted as include directives[...]Similarly, lines starting with "-" exclude files even if they are found within an include filelist. +# For more examples or information refer to http://duplicity.nongnu.org/duplicity.1.html#sect10 +# INCEXCFILE=/path/to/file + +# EXCLUDE DEVICE FILES +# Exclude all device files. This can be useful for security/permissions reasons +# or if device files are not handled correctly. +# +# EXDEVICEFILES=1 + # STATIC BACKUP OPTIONS # Here you can define the static backup options that you want to run with diff --git a/duplicity-backup.sh b/duplicity-backup.sh index 26dc124..983c4f1 100755 --- a/duplicity-backup.sh +++ b/duplicity-backup.sh @@ -249,6 +249,7 @@ check_variables () [[ ${LOGDIR} = "/home/foobar_user_name/logs/test2/" ]] && config_sanity_fail "LOGDIR must be configured" [[ ( ${DEST_IS_S3} = true && (${AWS_ACCESS_KEY_ID} = "foobar_aws_key_id" || ${AWS_SECRET_ACCESS_KEY} = "foobar_aws_access_key" )) ]] && \ config_sanity_fail "An s3 DEST has been specified, but AWS_ACCESS_KEY_ID or AWS_SECRET_ACCESS_KEY have not been configured" + [[ ! -z "$INCEXCFILE" && ! -f $INCEXCFILE ]] && config_sanity_fail "The specified INCEXCFILE $INCEXCFILE does not exists" } check_logdir() @@ -386,6 +387,12 @@ include_exclude() OLDIFS=$IFS IFS=$(echo -en "\t\n") + # Exlcude device files? + if [ ! -z $EXDEVICEFILES ] && [ $EXDEVICEFILES -ne 0 ]; then + TMP=" --exclude-device-files" + INCLUDE=$INCLUDE$TMP + fi + for include in ${INCLIST[@]} do TMP=" --include=""'"$include"'" @@ -398,13 +405,20 @@ include_exclude() EXCLUDE=$EXCLUDE$TMP done - # INCLIST is empty so every file needs to be saved - if [[ "$INCLIST" == '' ]]; then + # Include/Exclude globbing filelist + if [ $INCEXCFILE != '' ]; then + TMP=" --include-globbing-filelist ""'"$INCEXCFILE"'" + INCLUDE=$INCLUDE$TMP + fi + + # INCLIST and globbing filelist is empty so every file needs to be saved + if [ "$INCLIST" == '' ] && [ "$INCEXCFILE" == '' ]; then EXCLUDEROOT='' else EXCLUDEROOT="--exclude=**" fi - + + # Restore IFS IFS=$OLDIFS }