Add option to provide a destination path and/or new_name when restore a file
Diff
1diff --git a/dt-s3-backup.sh b/dt-s3-backup.sh
2index b1f56adf188fa18c935cfd5805cd672230611f32..34322bdd7c3cabfb1a4663a111c4b60d54ff4668 100755
3--- a/dt-s3-backup.sh
4+++ b/dt-s3-backup.sh
5@@ -377,9 +377,15 @@ elif [ "$1" = "--restore-file" ]; then
6 echo "Please provide file to restore (eg. Mail/article):"
7 read -e FILE_TO_RESTORE
8 FILE_TO_RESTORE=$FILE_TO_RESTORE
9- DEST=$FILE_TO_RESTORE
10+ echo "Would you like to provide new filename? [No/...path/new_name]:"
11+ read -e DEST_PATH
12+ if [ "$DEST_PATH" = "No" ]; then
13+ DEST=$FILE_TO_RESTORE
14+ else
15+ DEST=$DEST_PATH
16+ fi
17 echo ">> You will restore your $FILE_TO_RESTORE to ${DEST} from ${ROOT}."
18- echo ">> You can override this question by executing '--restore-file [file]' next time"
19+ echo ">> You can override this question by executing '--restore-file [file] [[path/new_name]]' next time"
20 echo "Are you sure you want to do that ('yes' to continue)?"
21 read ANSWER
22 if [ "$ANSWER" != "yes" ]; then
23@@ -390,10 +396,14 @@ elif [ "$1" = "--restore-file" ]; then
24 echo "Restoring now ..."
25 else
26 FILE_TO_RESTORE=$2
27+ if [[ "$3" ]]; then
28+ DEST=$3
29+ else
30+ DEST=$FILE_TO_RESTORE
31+ fi
32 fi
33 #use INCLUDE variable without create another one
34 INCLUDE="--file-to-restore ${FILE_TO_RESTORE}"
35- DEST=$FILE_TO_RESTORE
36 duplicity_backup
3738 elif [ "$1" = "--list-current-files" ]; then
39@@ -422,7 +432,7 @@ else
4041 --verify: verifies the backup (no cleanup is run)
42 --restore [path]: restores the backup to specified path
43- --restore-file [file]: restore a specific files
44+ --restore-file [file] [[path/new_name]]: restore a specific files, optional you can provide a destination name
45 --list-current-files: lists the files currently backed up in the archive.
4647 --backup-script: let's you backup the script and secret key to the current working directory