From 900e209510a05af78595d0f5f57f27e0cc8e74fb Mon Sep 17 00:00:00 2001
From: David Beniamine <david.beniamine@tetras-libre.fr>
Date: Tue, 30 Mar 2021 16:42:33 +0200
Subject: [PATCH] Script to ease restoring files

---
 clear_backup.sh |  5 -----
 restore_file.sh | 22 ++++++++++++++++++++++
 2 files changed, 22 insertions(+), 5 deletions(-)
 create mode 100644 restore_file.sh

diff --git a/clear_backup.sh b/clear_backup.sh
index 941daf7..8cb9b41 100755
--- a/clear_backup.sh
+++ b/clear_backup.sh
@@ -3,11 +3,6 @@
 DIR=$(realpath $(dirname $0))
 source $DIR/inc.sh
 
-BK_FULL_FREQ="1M" # create a new full backup every...
-BK_FULL_LIFE="2M" # delete any backup older than this
-BK_KEEP_FULL="0"  # How many full+inc cycle to keep
-
-
 export PASSPHRASE="$encpass"
 export FTP_PASSWORD="$ftppass"
 #set -x
diff --git a/restore_file.sh b/restore_file.sh
new file mode 100644
index 0000000..5f1ba76
--- /dev/null
+++ b/restore_file.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+DIR=$(realpath $(dirname $0))
+source $DIR/inc.sh
+
+if [ -z "$2" ]; then
+    echo "Usage $0 <restore_path> <destination_path> [timeago]"
+    echo "restore_path      :   path to restore without leading slash"
+    echo "destination_path  :   path to download the file(s), duplicity will not override existing files"
+    echo "timeago           :   optionnal : the age of the version we want to restore, for instance 6D for 6 days ago"
+fi
+
+if [ ! -z "$3" ]; then
+    delay="-t $3"
+fi
+
+export PASSPHRASE="$encpass"
+export FTP_PASSWORD="$ftppass"
+
+/usr/bin/duplicity --file-to-restore $delay "$1" ftp://$user@$host/$remotedir/ "$2"
+
+unset PASSPHRASE
+unset FTP_PASSWORD
-- 
GitLab