22aad26fda7538d0ed5c466dc669b5ef4fea87c3

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

Message

v0.8.2 : Fix issue #5 "Handle --time option for restoration"

Diff

  1diff --git a/CHANGELOG b/CHANGELOG
  2index efec0e3c3d3240cfbad0855ed5e19f77ed8ed616..c8d6d661716beffbbf5c16f0c82a8f1b2047e04e 100644
  3--- a/CHANGELOG
  4+++ b/CHANGELOG
  5@@ -1,3 +1,11 @@
  6+0.8.2 (01 November 2012)
  7+========================
  8+  * Handle --time option for restoration and file-listing
  9+  * Fix "check_variables" not to throw errors if no encryption is desired
 10+  * Added mail option [philcryer]
 11+  * Fix issue #18: `which s3cmd` only called when dest is s3
 12+  * Added hint in the comments of the config file to use --s3-european-buckets option for european buckets
 13+
 14 0.8.1 (15 August 2012)
 15 ======================
 16   * Added support for using separate signature and encryption keys [puredoze]
 17diff --git a/README b/README
 18index da54be285e506afee8c4c60be3c78a40be61f75c..685bc600b548d913b38cd4fbe7b976376f78a93a 100644
 19--- a/README
 20+++ b/README
 21@@ -50,6 +50,7 @@ REQUIREMENTS
 22 
 23 * duplicity
 24 * gpg
 25+* which
 26 * Amazon S3 (optional)
 27 * s3cmd (optional)
 28 * mailx (optional)
 29@@ -97,6 +98,8 @@ USAGE
 30     -l, --list-current-files   lists the files currently backed up in the archive
 31     -s, --collection-status    show all the backup sets in the archive
 32 
 33+    -t, --time TIME            specify the time from which to restore or list 
 34+                               files (duplicity time format)
 35         --backup-script        automatically backup the script and secret key to
 36                                the current working directory
 37     -n, --dry-run              perform a trial run with no changes made
 38@@ -159,7 +162,5 @@ NEXT VERSION WISH LIST
 39 ======================
 40 
 41 * --restore-dir option
 42-* restore files from a specific time period
 43-* support multiple MTAs for the email alert feature
 44 
 45 Thanks to Mario Santagiuliana and Razvan for their help.
 46diff --git a/duplicity-backup.sh b/duplicity-backup.sh
 47index 15ae4c6465d5c658f29b5c44b58e1cc625cd45e2..3f130b8a0c395654c1893ec7a809585c7c3f5890 100755
 48--- a/duplicity-backup.sh
 49+++ b/duplicity-backup.sh
 50@@ -55,6 +55,7 @@ echo "USAGE:
 51     -s, --collection-status    show all the backup sets in the archive
 52         --backup-script        automatically backup the script and secret key to
 53                                the current working directory
 54+    -t, --time TIME            specify the time from which to restore or list files
 55     -n, --dry-run              perform a trial run with no changes made
 56 
 57   CURRENT SCRIPT VARIABLES:
 58@@ -70,7 +71,7 @@ echo "USAGE:
 59 # Some expensive argument parsing that allows the script to
 60 # be insensitive to the order of appearance of the options
 61 # and to handle correctly option parameters that are optional
 62-while getopts ":c:bfvlsn-:" opt; do
 63+while getopts ":c:t:bfvlsn-:" opt; do
 64   case $opt in
 65     # parse long options (a bit tricky because builtin getopts does not
 66     # manage long options and i don't want to impose GNU getopt dependancy)
 67@@ -108,6 +109,13 @@ while getopts ":c:bfvlsn-:" opt; do
 68             OPTIND=$(( $OPTIND + 1 )) # we found it, move forward in arg parsing
 69           fi
 70         ;;
 71+        time) # set the restore time from the command line
 72+          # We try to find the restore time
 73+          if [ ! -z "${!OPTIND:0:1}" -a ! "${!OPTIND:0:1}" = "-" ]; then
 74+            TIME=${!OPTIND}
 75+            OPTIND=$(( $OPTIND + 1 )) # we found it, move forward in arg parsing
 76+          fi
 77+        ;;
 78         dry-run)
 79           ECHO=$(which echo)
 80         ;;
 81@@ -118,6 +126,7 @@ while getopts ":c:bfvlsn-:" opt; do
 82     ;;
 83     # here are parsed the short options
 84     c) CONFIG=$OPTARG;; # set the config file from the command line
 85+    t) TIME=$OPTARG;; # set the restore time from the command line
 86     b) COMMAND="backup";;
 87     f) COMMAND="full";;
 88     v) COMMAND="verify";;
 89@@ -495,6 +504,9 @@ case "$COMMAND" in
 90   "restore")
 91     ROOT=$DEST
 92     OPTION="restore"
 93+    if [ ! -z "$TIME" ]; then
 94+      STATIC_OPTIONS="$STATIC_OPTIONS --time $TIME"
 95+    fi
 96 
 97     if [[ ! "$RESTORE_DEST" ]]; then
 98       echo "Please provide a destination path (eg, /home/user/dir):"
 99@@ -524,6 +536,10 @@ case "$COMMAND" in
100     EXLUDEROOT=
101     OPTION=
102 
103+    if [ ! -z "$TIME" ]; then
104+      STATIC_OPTIONS="$STATIC_OPTIONS --time $TIME"
105+    fi
106+
107     if [[ ! "$FILE_TO_RESTORE" ]]; then
108       echo "Which file do you want to restore (eg, mail/letter.txt):"
109       read -e FILE_TO_RESTORE
110@@ -559,6 +575,11 @@ case "$COMMAND" in
111 
112   "list-current-files")
113     OPTION="list-current-files"
114+
115+    if [ ! -z "$TIME" ]; then
116+      STATIC_OPTIONS="$STATIC_OPTIONS --time $TIME"
117+    fi
118+
119     ${DUPLICITY} ${OPTION} ${VERBOSITY} ${STATIC_OPTIONS} \
120     $ENCRYPT \
121     ${DEST}