a2204bf1dcbdd5c1fb0ae4cae23ed367be3add04

Author
Johan Piper <johan.lt.piper@gmail.com>
Committer
Johan Piper <johan.lt.piper@gmail.com>
Date

Message

Merged https://github.com/zertrin/duplicity-backup.git

Conflicts (straight-forward resolution):
	README.md

Diff

This diff is truncated to protect this page.

  1diff --git a/README.md b/README.md
  2index edc61f4835cc42f1295ca648fd89de5471d2aec4..eebb91d66c094f8ff718b53e1f07efe936308a95 100644
  3--- a/README.md
  4+++ b/README.md
  5@@ -10,6 +10,7 @@ Optionally, you can set up an email address where the log file will be sent, whi
  6 
  7 This version is a rewriting of the code originally written by [Damon Timm](https://github.com/thornomad), including many patches that have been brought to the original scripts by various forks on Github.
  8 
  9+
 10 ## Contributing
 11 
 12 Latest version of the code is available at http://github.com/zertrin/duplicity-backup
 13@@ -53,7 +54,7 @@ The script looks for its configuration by reading the config file specified by t
 14 If no config file was given on the command line, the script will try to find the file specified in the `CONFIG` parameter at the beginning of the script (default: `duplicity-backup.conf` in the script's directory).
 15 
 16 So be sure to either:
 17-* specify the configuration file path on the command line **[recommended]**
 18+* specify the configuration file path on the command line with the -c option **[recommended]**
 19 * or to edit the `CONFIG` parameter in the script to match the actual location of your config file. **[deprecated]**
 20 
 21 NOTE: to ease future updates of the script, you may prefer NOT to edit the script at all and to specify systematically the path to your config file on the command line with the `-c` or `--config` option.
 22@@ -68,19 +69,22 @@ NOTE: to ease future updates of the script, you may prefer NOT to edit the scrip
 23 
 24         -b, --backup               runs an incremental backup
 25         -f, --full                 forces a full backup
 26-
 27         -v, --verify               verifies the backup
 28+        -l, --list-current-files   lists the files currently backed up in the archive
 29+        -s, --collection-status    show all the backup sets in the archive
 30+
 31             --restore [PATH]       restores the entire backup to [path]
 32             --restore-file [FILE_TO_RESTORE] [DESTINATION]
 33                                    restore a specific file
 34+            --restore-dir [DIR_TO_RESTORE] [DESTINATION]
 35+                                   restore a specific directory
 36 
 37-        -l, --list-current-files   lists the files currently backed up in the archive
 38-        -s, --collection-status    show all the backup sets in the archive
 39+        -t, --time TIME            specify the time from which to restore or list files
 40+                                   (see duplicity man page for the format)
 41 
 42-        -t, --time TIME            specify the time from which to restore or list 
 43-                                   files (duplicity time format)
 44-            --backup-script        automatically backup the script and secret key to
 45+        --backup-script            automatically backup the script and secret key(s) to
 46                                    the current working directory
 47+
 48         -n, --dry-run              perform a trial run with no changes made
 49         -d, --debug                echo duplicity commands to logfile
 50 
 51@@ -101,37 +105,41 @@ NOTE: to ease future updates of the script, you may prefer NOT to edit the scrip
 52 
 53 **Restore your entire backup:**
 54 
 55+    # You will be prompted for a restore directory
 56     duplicity-backup.sh [-c config_file] --restore
 57 
 58-*You will be prompted for a restore directory*
 59-
 60+    # You can also provide a restore folder on the command line.
 61     duplicity-backup.sh [-c config_file] --restore /home/user/restore-folder
 62 
 63-*You can also provide a restore folder on the command line.*
 64+**Restore a specific file or directory in the backup:**
 65 
 66-**Restore a specific file in the backup:**
 67+Note that the commands --restore-file and --restore-dir are equivalent.
 68 
 69+    # You will be prompted for a file to restore to the current directory
 70     duplicity-backup.sh [-c config_file] --restore-file
 71 
 72-*You will be prompted for a file to restore to the current directory*
 73-
 74+    # Restores the file img/mom.jpg to the current directory
 75     duplicity-backup.sh [-c config_file] --restore-file img/mom.jpg
 76 
 77-*Restores the file img/mom.jpg to the current directory*
 78-
 79+    # Restores the file img/mom.jpg to /home/user/i-love-mom.jpg
 80     duplicity-backup.sh [-c config_file] --restore-file img/mom.jpg /home/user/i-love-mom.jpg
 81 
 82-*Restores the file img/mom.jpg to /home/user/i-love-mom.jpg*
 83+    # Restores the directory rel/dir/path to /target/restorepath
 84+    duplicity-backup.sh [-c config_file] --restore-dir rel/dir/path /target/restorepath
 85 
 86 **List files in the remote archive**
 87 
 88     duplicity-backup.sh [-c config_file] --list-current-files
 89 
 90+**See the collection status (i.e. all the backup sets in the remore archive)**
 91+
 92+    duplicity-backup.sh [-c config_file] --collection-status
 93+
 94 **Verify the backup**
 95 
 96     duplicity-backup.sh [-c config_file] --verify
 97 
 98-**Backup the script and gpg key (for safekeeping)**
 99+**Backup the script and gpg key in a encrypted tarfile (for safekeeping)**
100 
101     duplicity-backup.sh [-c config_file] --backup-script
102 
103@@ -149,7 +157,9 @@ To see exactly what is happening when you run duplicity-backup, either pass the
104 
105diff --git a/duplicity-backup.conf.example b/duplicity-backup.conf.example
106index c81aaf7bed51704a89b8fc5d59d71d5ed39476f2..04d8f0906422fcb0e27a1070ab0700882ec64349 100644
107--- a/duplicity-backup.conf.example
108+++ b/duplicity-backup.conf.example
109@@ -2,7 +2,7 @@
110 #
111 # Copyright (c) 2008-2010 Damon Timm.
112 # Copyright (c) 2010 Mario Santagiuliana.
113-# Copyright (c) 2012 Marc Gallet.
114+# Copyright (c) 2012-2013 Marc Gallet.
115 #
116 # This program is free software: you can redistribute it and/or modify it under
117 # the terms of the GNU General Public License as published by the Free Software
118@@ -25,6 +25,9 @@
119 # Latest code available at:
120 # http://github.com/zertrin/duplicity-backup
121 #
122+# List of contributors:
123+# https://github.com/zertrin/duplicity-backup/graphs/contributors
124+#
125 # ---------------------------------------------------------------------------- #
126 
127 # #############################################
128@@ -87,7 +90,7 @@ ROOT="/home"
129 # BACKUP DESTINATION INFORMATION
130 # In my case, I use Amazon S3 use this - so I made up a unique
131 # bucket name (you don't have to have one created, it will do it
132-# for you).  If you don't want to use Amazon S3, you can backup
133+# for you). If you don't want to use Amazon S3, you can backup
134 # to a file or any of duplicity's supported outputs.
135 #
136 # The s3+http scheme uses the default aws s3 hostname.
137@@ -97,12 +100,19 @@ ROOT="/home"
138 # remote file size check will work.
139 #DEST="s3://host/backup-bucket/backup-folder/"
140 DEST="s3+http://foobar-backup-bucket/backup-folder/"
141+#
142 # Other possible locations
143+# Be sure to check duplicity's man page to know how to use them
144+# (http://duplicity.nongnu.org/duplicity.1.html)
145+#
146 #DEST="ftp://user[:password]@other.host[:port]/some_dir"
147 #DEST="rsync://user@host.com[:port]//absolute_path"
148 #DEST="scp://user[:password]@other.host[:port]/[/]some_dir"
149 #DEST="ssh://user[:password]@other.host[:port]/[/]some_dir"
150+#DEST="sftp://user[:password]@other.host[:port]/[/]some_dir"
151 #DEST="file:///home/foobar_user_name/new-backup-test/"
152+#DEST="imap[s]://user[:password]@host.com[/from_address_prefix]"
153+#DEST="webdav[s]://user[:password]@other.host[:port]/some_dir"
154 
155 # DESTINATION BACKEND PASSWORD
156 # Instead of setting the password needed for the backup destination in the
157@@ -116,7 +126,7 @@ DEST="s3+http://foobar-backup-bucket/backup-folder/"
158 
159 # INCLUDE LIST OF DIRECTORIES
160 # Here is a list of directories to include; if you want to include
161-# everything that is in root, leave this list empty.
162+# everything that is in ROOT, leave this list empty.
163 #
164 # Here is an example with multiple locations:
165 #INCLIST=(  "/home/*/Documents" \
166@@ -209,6 +219,7 @@ MAIL="mailx"     # default command for Linux mail
167 #MAIL="mail"     # for CentOS, if "mailx" fails try this one
168 #MAIL="ssmtp"
169 #MAIL="sendmail"
170+#MAIL="msmtp"
171 
172 # TROUBLESHOOTING: If you are having any problems running this script it is
173 # helpful to see the command output that is being generated to determine if the
174diff --git a/duplicity-backup.sh b/duplicity-backup.sh
175index 235586bf34ba109747c335b6f75c3e65000bea03..26dc124eebfd5a30d55c3f9de787ba40e62b518a 100755
176--- a/duplicity-backup.sh
177+++ b/duplicity-backup.sh
178@@ -48,14 +48,21 @@ echo "USAGE:
179     -b, --backup               runs an incremental backup
180     -f, --full                 forces a full backup
181     -v, --verify               verifies the backup
182+    -l, --list-current-files   lists the files currently backed up in the archive
183+    -s, --collection-status    show all the backup sets in the archive
184+
185         --restore [PATH]       restores the entire backup to [path]
186         --restore-file [FILE_TO_RESTORE] [DESTINATION]
187                                restore a specific file
188-    -l, --list-current-files   lists the files currently backed up in the archive
189-    -s, --collection-status    show all the backup sets in the archive
190-        --backup-script        automatically backup the script and secret key to
191-                               the current working directory
192+        --restore-dir [DIR_TO_RESTORE] [DESTINATION]
193+                               restore a specific directory
194+
195     -t, --time TIME            specify the time from which to restore or list files
196+                               (see duplicity man page for the format)
197+
198+    --backup-script            automatically backup the script and secret key(s) to
199+                               the current working directory
200+
201     -n, --dry-run              perform a trial run with no changes made
202     -d, --debug                echo duplicity commands to logfile
203 
204@@ -75,7 +82,7 @@ echo "USAGE:
205 while getopts ":c:t:bfvlsnd-:" opt; do
206   case $opt in
207     # parse long options (a bit tricky because builtin getopts does not
208-    # manage long options and i don't want to impose GNU getopt dependancy)
209+    # manage long options and I don't want to impose GNU getopt dependancy)
210     -)
211       case "$OPTARG" in
212         # --restore [restore dest]
213@@ -88,7 +95,8 @@ while getopts ":c:t:bfvlsnd-:" opt; do
214           fi
215         ;;
216         # --restore-file [file to restore] [restore dest]
217-        restore-file)
218+        # --restore-dir [path to restore] [restore dest]
219+        restore-file|restore-dir)
220           COMMAND=$OPTARG
221           # We try to find the first optional value [file to restore]
222           if [ ! -z "${!OPTIND:0:1}" -a ! "${!OPTIND:0:1}" = "-" ]; then
223@@ -271,6 +279,8 @@ email_logfile()
224           EMAIL_SUBJECT=${EMAIL_SUBJECT:="duplicity-backup alert ${LOG_FILE}"}
225           if [ "$MAIL" = "ssmtp" ]; then
226             echo """Subject: ${EMAIL_SUBJECT}""" | cat - ${LOGFILE} | ${MAILCMD} -s ${EMAIL_TO}
227+          elif [ "$MAIL" = "msmtp" ]; then
228+            echo """Subject: ${EMAIL_SUBJECT}""" | cat - ${LOGFILE} | ${MAILCMD} ${EMAIL_TO}
229           elif [ "$MAIL" = "mailx" ]; then
230             EMAIL_FROM=${EMAIL_FROM:+"-r ${EMAIL_FROM}"}
231             cat ${LOGFILE} | ${MAILCMD} -s """${EMAIL_SUBJECT}""" $EMAIL_FROM ${EMAIL_TO}
232@@ -522,7 +532,7 @@ get_lock
233 
234 INCLUDE=
235 EXCLUDE=
236-EXLUDEROOT=
237+EXCLUDEROOT=
238 
239 case "$COMMAND" in
240   "backup-script")
241@@ -587,16 +597,17 @@ case "$COMMAND" in
242     duplicity_backup
243   ;;
244 
245-  "restore-file")
246+  "restore-file"|"restore-dir")
247     ROOT=$DEST
248-    OPTION=
249+    OPTION="restore"
250 
251     if [ ! -z "$TIME" ]; then
252       STATIC_OPTIONS="$STATIC_OPTIONS --time $TIME"
253     fi
254 
255     if [[ ! "$FILE_TO_RESTORE" ]]; then
256-      echo "Which file do you want to restore (eg, mail/letter.txt):"
257+      echo "Which file or directory do you want to restore?"
258+      echo "(give the path relative to the root of the backup eg, mail/letter.txt):"
259       read -e FILE_TO_RESTORE
260       echo
261     fi
262@@ -623,7 +634,7 @@ case "$COMMAND" in
263 
264     setup_passphrase
265     echo "Restoring now ..."
266-    #use INCLUDE variable without create another one
267+    #use INCLUDE variable without creating another one
268     INCLUDE="--file-to-restore ${FILE_TO_RESTORE}"
269     duplicity_backup
270   ;;