7d836294ceceb6e07e21baac2ee79086c155698d

Author
jaltek <puredoze@gmail.com>
Committer
jaltek <puredoze@gmail.com>
Date

Message

Fixes issue zertrin/duplicity-backup/issues/41

Diff

 1diff --git a/duplicity-backup.conf.example b/duplicity-backup.conf.example
 2index 04d8f0906422fcb0e27a1070ab0700882ec64349..73c173e80b6e064a89897ccff5d733750badfe2f 100644
 3--- a/duplicity-backup.conf.example
 4+++ b/duplicity-backup.conf.example
 5@@ -136,7 +136,7 @@ DEST="s3+http://foobar-backup-bucket/backup-folder/"
 6 #        )
 7 #
 8 # Simpler example with one location:
 9-INCLIST=( "/home/foobar_user_name/Documents/" )
10+# INCLIST=( "/home/foobar_user_name/Documents/" )
11 
12 # EXCLUDE LIST OF DIRECTORIES
13 # Even though I am being specific about what I want to include,
14@@ -151,7 +151,31 @@ INCLIST=( "/home/foobar_user_name/Documents/" )
15 #            "/**.AppleDouble" \
16 #        )
17 # Simpler example with one location. Adapt it to your needs.
18-EXCLIST=( "/home/foobar_user_name/Documents/foobar-to-exclude" )
19+# EXCLIST=( "/home/foobar_user_name/Documents/foobar-to-exclude" )
20+
21+# INCLUDE GLOBBING FILELIST
22+# Instead of using the INCLIST/EXCLIST variable you can also define a special 
23+# (text-)file where each line in the filelist will be interpreted as 
24+# a globbing pattern. By using the '+' or '-' sign at the beginning of each line 
25+# you are able to specify if the folder should be included or excluded. 
26+# 
27+# 
28+# Example:
29+# 	+ /dir/foo 
30+# 	- /dir/foob*
31+# 	+ /dir/*
32+# 
33+# From the duplicity manual: 	
34+# Lines starting with "+" are interpreted as include directives[...]Similarly, lines starting with "-" exclude files even if they are found within an include filelist.
35+# For more examples or information refer to http://duplicity.nongnu.org/duplicity.1.html#sect10
36+# INCEXCFILE=/path/to/file
37+
38+# EXCLUDE DEVICE FILES
39+# Exclude all device files. This can be useful for security/permissions reasons 
40+# or if device files are not handled correctly.
41+# 
42+# EXDEVICEFILES=1
43+
44 
45 # STATIC BACKUP OPTIONS
46 # Here you can define the static backup options that you want to run with
47diff --git a/duplicity-backup.sh b/duplicity-backup.sh
48index 26dc124eebfd5a30d55c3f9de787ba40e62b518a..983c4f124aa4b92d7ae50a44ab12f3668cb65a3f 100755
49--- a/duplicity-backup.sh
50+++ b/duplicity-backup.sh
51@@ -249,6 +249,7 @@ check_variables ()
52   [[ ${LOGDIR} = "/home/foobar_user_name/logs/test2/" ]] && config_sanity_fail "LOGDIR must be configured"
53   [[ ( ${DEST_IS_S3} = true && (${AWS_ACCESS_KEY_ID} = "foobar_aws_key_id" || ${AWS_SECRET_ACCESS_KEY} = "foobar_aws_access_key" )) ]] && \
54   config_sanity_fail "An s3 DEST has been specified, but AWS_ACCESS_KEY_ID or AWS_SECRET_ACCESS_KEY have not been configured"
55+  [[ ! -z "$INCEXCFILE" && ! -f $INCEXCFILE ]] && config_sanity_fail "The specified INCEXCFILE $INCEXCFILE does not exists"
56 }
57 
58 check_logdir()
59@@ -386,6 +387,12 @@ include_exclude()
60   OLDIFS=$IFS
61   IFS=$(echo -en "\t\n")
62 
63+  # Exlcude device files?
64+  if [ ! -z $EXDEVICEFILES ] && [ $EXDEVICEFILES -ne 0 ]; then
65+    TMP=" --exclude-device-files"
66+    INCLUDE=$INCLUDE$TMP
67+  fi
68+  
69   for include in ${INCLIST[@]}
70   do
71     TMP=" --include=""'"$include"'"
72@@ -398,13 +405,20 @@ include_exclude()
73     EXCLUDE=$EXCLUDE$TMP
74   done
75   
76-  # INCLIST is empty so every file needs to be saved
77-  if [[ "$INCLIST" == '' ]]; then
78+  # Include/Exclude globbing filelist
79+  if [ $INCEXCFILE != '' ]; then
80+    TMP=" --include-globbing-filelist ""'"$INCEXCFILE"'"
81+    INCLUDE=$INCLUDE$TMP
82+  fi
83+  
84+  # INCLIST and globbing filelist is empty so every file needs to be saved
85+  if [ "$INCLIST" == '' ] && [ "$INCEXCFILE" == '' ]; then
86     EXCLUDEROOT=''
87   else
88     EXCLUDEROOT="--exclude=**"
89   fi
90-
91+  
92+  
93   # Restore IFS
94   IFS=$OLDIFS
95 }