From 42d897f3acf22ea1b35fede0d318d7dced9c0676 Mon Sep 17 00:00:00 2001 From: Djan GICQUEL <> Date: Sun, 22 May 2022 11:37:19 +0200 Subject: [PATCH] inital version --- reborg.sh | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100755 reborg.sh diff --git a/reborg.sh b/reborg.sh new file mode 100755 index 0000000..b0a50d0 --- /dev/null +++ b/reborg.sh @@ -0,0 +1,65 @@ +#! /bin/bash +# reborg.sh +# A script for migrating borg repos +# for example from clear repo to encrypted repo +# by Djan GICQUEL +# Licence : CC SA-NC + +repo1="" +repo2="" +txtfile="" + +#----------------------------------------------------------- + +if [ "$repo1" = "" ];then +echo "repo1 is empty";exit +fi + +if [ "$repo2" = "" ];then +echo "repo2 is empty";exit +fi + +if [ ! -f "config" "$repo1" ]; then +echo "unable to find borgbackup repo config file.";sleep 3;exit +fi + +if [ ! -d "data" "$repo1" ]; then +echo "unable to find borgbackup data folder.";sleep 3;exit +fi + +if [ ! -f "config" "$repo2" ]; then +echo "unable to find borgbackup repo config file.";sleep 3;exit +fi + +if [ ! -d "data" "$repo2" ]; then +echo "unable to find borgbackup data folder.";sleep 3;exit +fi + + +echo "$repo1" +echo "will be imported in" +echo "$repo2" +echo "" +read -p "OK ?" CONTINUE + +if [ -f reborg_repo1.txt ];then + echo "File exist, resuming." +else + echo "$(borg list --format='{archive} {time:%Y-%m-%dT%H:%M:%S}{LF}' $repo1)" > $txtfile + echo "archive list genereted" + read -p "Continue ?" CONTINUE +fi + +cat reborg_repo1.txt | while read A T;do +echo "Importing $A..." +borg export-tar $repo1::$A - | borg import-tar --timestamp=$T $repo2::$A - +echo "Archive $A imported." +echo "" +tail -n +2 "$txtfile" > "$txtfile.tmp" && mv "$txtfile.tmp" "$txtfile" +done + +echo "Deleting $txtfile" +rm reborg_repo1.txt + +echo "" +echo "End of the script."