inital version

This commit is contained in:
Djan GICQUEL 2022-05-22 11:37:19 +02:00
commit 42d897f3ac

65
reborg.sh Executable file
View File

@ -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."