9b34c0480299617ba49d8a7d97e60eccfb494f04

Author
Ville Walveranta <vwal@astronfortis.com>
Committer
Ville Walveranta <vwal@astronfortis.com>
Date

Message

Adds the option to use remove-all-inc-of-but-n-full to prune incrementals of backups with long history.

Diff

 1diff --git a/duplicity-backup.conf.example b/duplicity-backup.conf.example
 2index bde6dc9accfa39ba4ed4f7eeec45db2c0b0ac481..682f84e118fc928ce7767a8e871146b545fc8fc8 100644
 3--- a/duplicity-backup.conf.example
 4+++ b/duplicity-backup.conf.example
 5@@ -144,6 +144,21 @@ STATIC_OPTIONS="--full-if-older-than 14D --s3-use-new-style"
 6 # You can either remove older than a specific time period:
 7 #CLEAN_UP_TYPE="remove-older-than"
 8 #CLEAN_UP_VARIABLE="31D"
 9+#
10+# In combination with "remove-older-than" clean-up type, you may want
11+# to keep only the full backups older than (n) number backup sets. For example, 
12+# let's say you set to CLEAN_UP_TYPE="remove-older-than", CLEAN_UP_VARIABLE
13+# to "6M" (six months), STATIC_OPTIONS to "--full-if-older-than 7D"
14+# (a full backup every 7 days), and you execute duplicity-backup once a day. 
15+# After six months you'll have 25 full backups, each with daily incrementals 
16+# in between. Perhaps you're keeping the backups past 1 month "just in case", 
17+# and so the older incrementals are overkill – weekly full backups beyond
18+# one month backward would suffice. In this case you can set 
19+# "REMOVE_INCREMENTALS_OLDER_THAN to, say, "4" which will delete the 
20+# incrementals for backup sets beyond the four most recent, keeping 
21+# only the full weekly backups for those backup sets. The incrementals
22+# for the four most recent backup sets remain untouched.
23+#REMOVE_INCREMENTALS_OLDER_THAN="4"
24 
25 # Or, If you would rather keep a certain (n) number of full backups (rather
26 # than removing the files based on their age), you can use what I use:
27diff --git a/duplicity-backup.sh b/duplicity-backup.sh
28index 9f40ef780c1b3a1fbf542dd1b483fa6b56455154..c926c1b71ba75419591b425a4eb8864549480932 100755
29--- a/duplicity-backup.sh
30+++ b/duplicity-backup.sh
31@@ -391,6 +391,13 @@ duplicity_cleanup()
32       ${ENCRYPT} \
33       ${DEST} >> ${LOGFILE}
34   echo >> ${LOGFILE}
35+  if [ ! -z ${REMOVE_INCREMENTALS_OLDER_THAN} ] && [[ ${REMOVE_INCREMENTALS_OLDER_THAN} =~ ^[0-9]+$ ]]; then
36+    eval ${ECHO} ${DUPLICITY} remove-all-inc-of-but-n-full ${REMOVE_INCREMENTALS_OLDER_THAN} \
37+      ${STATIC_OPTIONS} --force \
38+      ${ENCRYPT} \
39+      ${DEST} >> ${LOGFILE}
40+    echo >> ${LOGFILE}
41+  fi  
42 }
43 
44 duplicity_backup()