03ef054cf3c08635a40402c1fa932e184463cb59

Author
zertrin <zertrin@gmail.com>
Committer
zertrin <zertrin@gmail.com>
Date

Message

Add the --restore-dir synonym and update the documentation accordingly

Diff

This diff is truncated to protect this page.

  1diff --git a/README.md b/README.md
  2index 659425cd541a82ef3dcb6bcf9c5276c1a44f09c7..7d01c5605dd8bc20018f046f4357dec6297bf297 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@@ -150,6 +158,8 @@ To see exactly what is happening when you run duplicity-backup, either pass the
104 This will stop the script from running and will, instead, output the generated command into your log file. You can then check to see if what is being generated is causing an error or if it is duplicity causing you woe.
105diff --git a/duplicity-backup.sh b/duplicity-backup.sh
106index 6dec36fbe9fb56430cd57cd95ad80215b4701ee6..0a338ac76ca34f201b85ba93d7b84ba1b9a93096 100755
107--- a/duplicity-backup.sh
108+++ b/duplicity-backup.sh
109@@ -48,14 +48,21 @@ echo "USAGE:
110     -b, --backup               runs an incremental backup
111     -f, --full                 forces a full backup
112     -v, --verify               verifies the backup
113+    -l, --list-current-files   lists the files currently backed up in the archive
114+    -s, --collection-status    show all the backup sets in the archive
115+
116         --restore [PATH]       restores the entire backup to [path]
117         --restore-file [FILE_TO_RESTORE] [DESTINATION]
118                                restore a specific file
119-    -l, --list-current-files   lists the files currently backed up in the archive
120-    -s, --collection-status    show all the backup sets in the archive
121-        --backup-script        automatically backup the script and secret key to
122-                               the current working directory
123+        --restore-dir [DIR_TO_RESTORE] [DESTINATION]
124+                               restore a specific directory
125+
126     -t, --time TIME            specify the time from which to restore or list files
127+                               (see duplicity man page for the format)
128+
129+    --backup-script            automatically backup the script and secret key(s) to
130+                               the current working directory
131+
132     -n, --dry-run              perform a trial run with no changes made
133     -d, --debug                echo duplicity commands to logfile
134 
135@@ -88,7 +95,8 @@ while getopts ":c:t:bfvlsnd-:" opt; do
136           fi
137         ;;
138         # --restore-file [file to restore] [restore dest]
139-        restore-file)
140+        # --restore-dir [path to restore] [restore dest]
141+        restore-file|restore-dir)
142           COMMAND=$OPTARG
143           # We try to find the first optional value [file to restore]
144           if [ ! -z "${!OPTIND:0:1}" -a ! "${!OPTIND:0:1}" = "-" ]; then