Finish adding the backup scripts.

This commit is contained in:
Captain ALM 2024-08-30 13:16:28 +01:00
parent 837d75d003
commit dbffec2c4a
Signed by: alfred
GPG Key ID: 4E4ADD02609997B1
8 changed files with 92 additions and 15 deletions

View File

@ -12,7 +12,7 @@ else
fi fi
echo "Source Backup disk name: $1"; echo "Source Backup disk name: $1";
echo "Target Backup disk name: $2"; echo "Target Backup disk name: $2";
echo "Sync storage disk root path: $ssrc"; echo "Storage disk root path: $ssrc";
echo "Press Enter to Start..."; echo "Press Enter to Start...";
read; read;
echo "Copying..."; echo "Copying...";

View File

@ -12,7 +12,7 @@ else
fi fi
echo "Source Backup disk name: $1"; echo "Source Backup disk name: $1";
echo "Target Backup disk name: $2"; echo "Target Backup disk name: $2";
echo "Sync storage disk root path: $ssrc"; echo "Storage disk root path: $ssrc";
echo "Press Enter to Start..."; echo "Press Enter to Start...";
read; read;
echo "Moving..."; echo "Moving...";

View File

@ -11,7 +11,7 @@ else
ssrc="$2"; ssrc="$2";
fi fi
echo "Source Backup disk name: $1"; echo "Source Backup disk name: $1";
echo "Sync storage disk root path: $ssrc"; echo "Storage disk root path: $ssrc";
echo "Press Enter to Start..."; echo "Press Enter to Start...";
read; read;
echo "Deleting..."; echo "Deleting...";

View File

@ -17,7 +17,7 @@ if [ $? -ne 0 ]; then
echo "Hashes do not match!"; echo "Hashes do not match!";
exit 1; exit 1;
fi fi
(sha512sum "/mnt/tabls/$1.tbl" > "/tmp/a/$1.tbl.sum") && dd "if=/tmp/a/$1.tbl.sum" bs=128 count=1 "of=/mnt/hsums/$1-tbl.hash"; (sha512sum "/mnt/tabls/$1.tbl" > "/tmp/a/$1.tbl.sum") && dd "if=/tmp/a/$1.tbl.sum" bs=128 count=1 "of=/tmp/a/$1-tbl.hash";
cmp -s "/tmp/a/$1-tbl.hash" "/mnt/hsums/$1-tbl.hash"; cmp -s "/tmp/a/$1-tbl.hash" "/mnt/hsums/$1-tbl.hash";
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Partition hashes do not match!"; echo "Partition hashes do not match!";

30
backup-image/sync-all.sh Executable file
View File

@ -0,0 +1,30 @@
#/bin/bash
echo "Sync All Backups!";
if [ $# -eq 0 ]; then
echo "Usage: sync-all.sh <Target disk root path> [Source disk root path]";
exit 2;
fi
ssrc="";
if [ -z $2 ]; then
ssrc="/mnt";
else
ssrc="$2";
fi
echo "Target disk root path: $1";
echo "Source disk root path: $ssrc";
if [[ "$3" != "ikwid" ]]; then
echo "Press Enter to Start...";
read;
fi
rval=0;
for cf in $ssrc/tabls/*; do
if [ -e "$cf" ] && [ -f "$cf" ]; then
./sync.sh $(basename "$cf" ".tbl") "$1" "$ssrc" "ikwid";
if [ $? -ne 0 ]; then
echo "Sync failed: $cf";
rval=1;
fi
fi
done
echo "Finished!";
exit $rval;

View File

@ -13,15 +13,31 @@ fi
echo "Source Backup disk name: $1"; echo "Source Backup disk name: $1";
echo "Sync target disk root path: $2"; echo "Sync target disk root path: $2";
echo "Sync source disk root path: $ssrc"; echo "Sync source disk root path: $ssrc";
echo "Press Enter to Start..."; if [[ "$4" != "ikwid" ]]; then
read; echo "Press Enter to Start...";
read;
fi
mkdir -p /tmp/a; mkdir -p /tmp/a;
echo "Syncing..."; echo "Syncing...";
cp -f "$ssrc/hsums/$1-gz.hash" "$2/hsums/$1-gz.hash"; cmp -s "$ssrc/hsums/$1-tbl.hash" "$2/hsums/$1-tbl.hash"
cp -f "$ssrc/hsums/$1-tbl.hash" "$2/hsums/$1-tbl.hash"; sTbl=$?;
cp -f "$ssrc/hsums/$1.hash" "$2/hsums/$1.hash"; cmp -s "$ssrc/hsums/$1-gz.hash" "$2/hsums/$1-gz.hash";
cp -f "$ssrc/parts/$1.part.gz" "$2/parts/$1.part.gz"; sPart=$?;
cp -f "$ssrc/tabls/$1.tbl" "$2/tabls/$1.tbl"; if [ $sPart -eq 0 ]; then
cmp -s "$ssrc/hsums/$1.hash" "$2/hsums/$1.hash";
sPart=$?;
fi
if [ $sTbl -ne 0 ]; then
echo "Syncing: $1.tbl";
cp -f "$ssrc/tabls/$1.tbl" "$2/tabls/$1.tbl";
cp -f "$ssrc/hsums/$1-tbl.hash" "$2/hsums/$1-tbl.hash";
fi
if [ $sPart -ne 0 ]; then
echo "Syncing: $1.part.gz";
cp -f "$ssrc/hsums/$1-gz.hash" "$2/hsums/$1-gz.hash";
cp -f "$ssrc/hsums/$1.hash" "$2/hsums/$1.hash";
cp -f "$ssrc/parts/$1.part.gz" "$2/parts/$1.part.gz";
fi
echo "Verifying..."; echo "Verifying...";
cmp -s "$ssrc/hsums/$1-gz.hash" "$2/hsums/$1-gz.hash"; cmp -s "$ssrc/hsums/$1-gz.hash" "$2/hsums/$1-gz.hash";
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then

29
backup-image/verify-all.sh Executable file
View File

@ -0,0 +1,29 @@
#/bin/bash
echo "Verify All Backups!";
if [ $# -eq 0 ]; then
echo "Usage: verify-all.sh [Storage disk root path]";
exit 2;
fi
ssrc="";
if [ -z $1 ]; then
ssrc="/mnt";
else
ssrc="$1";
fi
echo "Storage disk root path: $ssrc";
if [[ "$2" != "ikwid" ]]; then
echo "Press Enter to Start...";
read;
fi
rval=0;
for cf in $ssrc/tabls/*; do
if [ -e "$cf" ] && [ -f "$cf" ]; then
./verify.sh $(basename "$cf" ".tbl") "$ssrc" "ikwid";
if [ $? -ne 0 ]; then
echo "Verify failed: $cf";
rval=1;
fi
fi
done
echo "Finished!";
exit $rval;

View File

@ -11,14 +11,16 @@ else
ssrc="$2"; ssrc="$2";
fi fi
echo "Source Backup disk name: $1"; echo "Source Backup disk name: $1";
echo "Sync storage disk root path: $ssrc"; echo "Storage disk root path: $ssrc";
echo "Press Enter to Start..."; if [[ "$3" != "ikwid" ]]; then
read; echo "Press Enter to Start...";
read;
fi
mkdir -p /tmp/a; mkdir -p /tmp/a;
echo "Verifying..."; echo "Verifying...";
echo "Calculating SHA512 sums..."; echo "Calculating SHA512 sums...";
((sha512sum "$ssrc/parts/$1.part.gz" > "/tmp/a/$1.part.gz.sum") && dd "if=/tmp/a/$1.part.gz.sum" bs=128 count=1 "of=/tmp/a/$1-gz.hash" && touch "/tmp/a/1.complete") & ((sha512sum "$ssrc/parts/$1.part.gz" > "/tmp/a/$1.part.gz.sum") && dd "if=/tmp/a/$1.part.gz.sum" bs=128 count=1 "of=/tmp/a/$1-gz.hash" && touch "/tmp/a/1.complete") &
((sha512sum "$ssrc/tabls/$1.tbl" > "/tmp/a/$1.tbl.sum") && dd "if=/tmp/a/$1.tbl.sum" bs=128 count=1 "of=/mnt/hsums/$1-tbl.hash" && touch "/tmp/a/2.complete") & ((sha512sum "$ssrc/tabls/$1.tbl" > "/tmp/a/$1.tbl.sum") && dd "if=/tmp/a/$1.tbl.sum" bs=128 count=1 "of=/tmp/a/$1-tbl.hash" && touch "/tmp/a/2.complete") &
until [ -f "/tmp/a/1.complete" ] && [ -f "/tmp/a/2.complete" ]; do sleep 0.1; done; until [ -f "/tmp/a/1.complete" ] && [ -f "/tmp/a/2.complete" ]; do sleep 0.1; done;
echo "Hashes:"; echo "Hashes:";
cat /tmp/a/*.sum; cat /tmp/a/*.sum;