From fe33569a1b5f7b5bb0a8c1a039a400d2dd8b42ae Mon Sep 17 00:00:00 2001 From: Captain ALM Date: Fri, 30 Aug 2024 13:23:36 +0100 Subject: [PATCH] Fix up backup syncing. --- backup-image/sync.sh | 57 ++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/backup-image/sync.sh b/backup-image/sync.sh index b22779e..32679ad 100755 --- a/backup-image/sync.sh +++ b/backup-image/sync.sh @@ -39,33 +39,38 @@ if [ $sPart -ne 0 ]; then cp -f "$ssrc/parts/$1.part.gz" "$2/parts/$1.part.gz"; fi echo "Verifying..."; -cmp -s "$ssrc/hsums/$1-gz.hash" "$2/hsums/$1-gz.hash"; -if [ $? -ne 0 ]; then - echo "Hash mismatch with $1-gz.hash !"; - exit 1; +if [ $sTbl -ne 0 ]; then + echo "Verifying: $1.tbl"; + cmp -s "$ssrc/hsums/$1-tbl.hash" "$2/hsums/$1-tbl.hash"; + if [ $? -ne 0 ]; then + echo "Hash mismatch with $1-tbl.hash !"; + exit 1; + fi + (sha512sum "$2/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" "$2/hsums/$1-tbl.hash"; + if [ $? -ne 0 ]; then + echo "Hash mismatch with $1.tbl !"; + exit 1; + fi fi -cmp -s "$ssrc/hsums/$1-tbl.hash" "$2/hsums/$1-tbl.hash"; -if [ $? -ne 0 ]; then - echo "Hash mismatch with $1-tbl.hash !"; - exit 1; -fi -cmp -s "$ssrc/hsums/$1.hash" "$2/hsums/$1.hash"; -if [ $? -ne 0 ]; then - echo "Hash mismatch with $1.hash !"; - exit 1; -fi -((sha512sum "$2/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 "$2/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; -cmp -s "/tmp/a/$1-gz.hash" "$2/hsums/$1-gz.hash"; -if [ $? -ne 0 ]; then - echo "Hash mismatch with $1.part.gz !"; - exit 1; -fi -cmp -s "/tmp/a/$1-tbl.hash" "$2/hsums/$1-tbl.hash"; -if [ $? -ne 0 ]; then - echo "Hash mismatch with $1.tbl !"; - exit 1; +if [ $sPart -ne 0 ]; then + echo "Verifying: $1.part.gz"; + cmp -s "$ssrc/hsums/$1-gz.hash" "$2/hsums/$1-gz.hash"; + if [ $? -ne 0 ]; then + echo "Hash mismatch with $1-gz.hash !"; + exit 1; + fi + cmp -s "$ssrc/hsums/$1.hash" "$2/hsums/$1.hash"; + if [ $? -ne 0 ]; then + echo "Hash mismatch with $1.hash !"; + exit 1; + fi + (sha512sum "$2/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"; + cmp -s "/tmp/a/$1-gz.hash" "$2/hsums/$1-gz.hash"; + if [ $? -ne 0 ]; then + echo "Hash mismatch with $1.part.gz !"; + exit 1; + fi fi rm -rf /tmp/a; echo "Finished!";