diff --git a/plugins/transfer/_template.sh b/plugins/transfer/_template.sh index 5eee9972bee87189fe85ece51cf721b17dc40664..d0f7e6e04b14683ac063efe339a02a1d46edd709 100644 --- a/plugins/transfer/_template.sh +++ b/plugins/transfer/_template.sh @@ -125,6 +125,16 @@ function t_sd_cmdPost(){ } +# -------------------------------------------------------------------------------- +# RESTORE +# -------------------------------------------------------------------------------- + + # show stored volumes on backup repository + # used in restore; directory param is checked before + # param string name of backup dir, i.e. /etc + function t_cmdShowVolumes(){ + } + # -------------------------------------------------------------------------------- # VERIFY RETURNCODES # -------------------------------------------------------------------------------- diff --git a/plugins/transfer/duplicity.sh b/plugins/transfer/duplicity.sh index b398da647db6dcea2b21620fbf88a92ac5de0059..1768e4720f6d8f2ecd299c18f93ff8774e5da6da 100644 --- a/plugins/transfer/duplicity.sh +++ b/plugins/transfer/duplicity.sh @@ -190,6 +190,39 @@ export PASSPHRASE } # -------------------------------------------------------------------------------- +# RESTORE +# -------------------------------------------------------------------------------- + + # show stored volumes on backup repository + # used in restore; directory param is checked before + # param string name of backup dir, i.e. /etc + function t_cmdShowVolumes(){ + tmpoutVolumes=/tmp/outvolumelist_$$ + + echo duplicity collection-status ${sParams} ${sTarget} + color cmd + duplicity collection-status ${sParams} ${sTarget} | tee -a $tmpoutVolumes + fetchrc + color reset + echo + + if [ `cat $tmpoutVolumes | egrep "(Full|Incremental)" | wc -l` -eq 0 ]; then + color error + echo "ERROR: no backup sets were found for directory [$sDir2restore]" + echo + color reset + sDir2restore= + setVars + else + color ok + echo "OK, `cat $tmpoutVolumes | grep "Full" | wc -l` Full and `cat $tmpoutVolumes | grep "Incremental" | wc -l` incremental backups" + color reset + fi + + rm -f $tmpoutVolumes + } + +# -------------------------------------------------------------------------------- # VERIFY RETURNCODES # -------------------------------------------------------------------------------- diff --git a/plugins/transfer/restic.sh b/plugins/transfer/restic.sh index 1c7d8fecbb88684c8186742e1a4bcd2eabedfc8b..6f916cd20248be93f466c6dadc97d7decee52630 100644 --- a/plugins/transfer/restic.sh +++ b/plugins/transfer/restic.sh @@ -36,6 +36,10 @@ # WORKAROUND for bug while writing on a SMB target export GODEBUG="asyncpreemptoff=1" + + RESTORE_ITEM=latest + RESTORE_FILTER= + RESTORE_CMD= } # -------------------------------------------------------------------------------- @@ -196,6 +200,54 @@ echo "Nothing here." } +# -------------------------------------------------------------------------------- +# RESTORE +# -------------------------------------------------------------------------------- + + # show stored volumes on backup repository + # used in restore; directory param is checked before + # param string name of backup dir, i.e. /etc + function t_cmdShowVolumes(){ + eval restic snapshots ${sParams} --path $sDir2restore + } + + # select a snapshot to restore from + function t_restoreSelect(){ + local _selid= + echo "--- Existing snapshots:" + color cmd + t_cmdShowVolumes + color reset + showPrompt "ID of the snapshot to restore from [$RESTORE_ITEM] >" + read _selid + test -z "$_selid" && _selid=$RESTORE_ITEM + RESTORE_ITEM=$_selid + echo using \"$RESTORE_ITEM\" + echo + } + # set a filter to reduce count of files to restore + function t_restoreFilter(){ + local _inc= + echo "--- Filter:" + echo "By default all files will be restored." + echo "You can limit it by setting include rules." + echo "You can enter ..." + echo " - a single directory name anywhere in the folderstructure" + echo " - a filename without path" + echo " - a filemask" + showPrompt "Include []>" + read _inc + RESTORE_FILTER="$_sIncParams $( t_getParamInlude "$_inc" )" + echo using parameter \"$RESTORE_FILTER\" + echo + } + # show stored volumes on backup repository + # used in restore; directory param is checked before + # param string name of backup dir, i.e. /etc + function t_cmdRestore(){ + echo "eval restic restore ${sParams} --path $sDir2restore --target ${sRestorepath} $RESTORE_FILTER $RESTORE_ITEM" + } + # -------------------------------------------------------------------------------- # VERIFY RETURNCODES # -------------------------------------------------------------------------------- @@ -219,7 +271,7 @@ color reset } - # repoitory cleanup + # repository cleanup function t_rcCheckCleanup(){ case $1 in 0) color ok; echo "OK" ;;