txtfile is now a variable and the script use it

This commit is contained in:
Djan GICQUEL 2022-06-12 17:40:25 +02:00
parent f95519281d
commit bfc2fd889a

View File

@ -19,19 +19,19 @@ if [ "$repo2" = "" ];then
echo "repo2 is empty";exit echo "repo2 is empty";exit
fi fi
if [ ! -f "config" "$repo1" ]; then if [ ! -f "$repo1/config" ]; then
echo "unable to find borgbackup repo config file.";sleep 3;exit echo "unable to find borgbackup repo config file.";sleep 3;exit
fi fi
if [ ! -d "data" "$repo1" ]; then if [ ! -d "$repo1/data" ]; then
echo "unable to find borgbackup data folder.";sleep 3;exit echo "unable to find borgbackup data folder.";sleep 3;exit
fi fi
if [ ! -f "config" "$repo2" ]; then if [ ! -f "$repo2/config" ]; then
echo "unable to find borgbackup repo config file.";sleep 3;exit echo "unable to find borgbackup repo config file.";sleep 3;exit
fi fi
if [ ! -d "data" "$repo2" ]; then if [ ! -d "$repo2/data" ]; then
echo "unable to find borgbackup data folder.";sleep 3;exit echo "unable to find borgbackup data folder.";sleep 3;exit
fi fi
@ -42,7 +42,7 @@ echo "$repo2"
echo "" echo ""
read -p "OK ?" CONTINUE read -p "OK ?" CONTINUE
if [ -f reborg_repo1.txt ];then if [ -f $txtfile ];then
echo "File exist, resuming." echo "File exist, resuming."
else else
echo "$(borg list --format='{archive} {time:%Y-%m-%dT%H:%M:%S}{LF}' $repo1)" > $txtfile echo "$(borg list --format='{archive} {time:%Y-%m-%dT%H:%M:%S}{LF}' $repo1)" > $txtfile
@ -50,7 +50,7 @@ else
read -p "Continue ?" CONTINUE read -p "Continue ?" CONTINUE
fi fi
cat reborg_repo1.txt | while read A T;do cat $txtfile | while read A T;do
echo "Importing $A..." echo "Importing $A..."
borg export-tar $repo1::$A - | borg import-tar --timestamp=$T $repo2::$A - borg export-tar $repo1::$A - | borg import-tar --timestamp=$T $repo2::$A -
echo "Archive $A imported." echo "Archive $A imported."
@ -59,7 +59,7 @@ tail -n +2 "$txtfile" > "$txtfile.tmp" && mv "$txtfile.tmp" "$txtfile"
done done
echo "Deleting $txtfile" echo "Deleting $txtfile"
rm reborg_repo1.txt rm $txtfile
echo "" echo ""
echo "End of the script." echo "End of the script."