From ab0944cbff29a36a400dc7fc8628e078a5d1f132 Mon Sep 17 00:00:00 2001 From: Bel LaPointe Date: Fri, 29 May 2020 07:32:26 -0600 Subject: [PATCH] restore doesnt need decimals --- backup.sh | 2 +- restore.sh | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/backup.sh b/backup.sh index 976f7f8..a7f2cc4 100755 --- a/backup.sh +++ b/backup.sh @@ -6,7 +6,7 @@ pg_dump $DATABASE_URL --clean > /mnt/save/$b/pg.dump \ echo "backup failed; deleting $b" exit 1 ) -if du -sh /mnt/save/$b | grep -Ei "^[ ]*(4|20).0K"; then +if du -sh /mnt/save/$b | grep -Ei "^[ ]*(4|2.).0K"; then rm -rf /mnt/save/$b echo rm empty backup $b fi diff --git a/restore.sh b/restore.sh index ff330fe..243c384 100755 --- a/restore.sh +++ b/restore.sh @@ -1,9 +1,16 @@ for b in $(find /mnt/save -type f | sort | tail -n 1); do - if [ -n "$b" ]; then - echo restoring $b + if [ -n "$b" ]; then + if du -sh "$b" | grep -Ei "^[ ]*(4|2[0-9])(.0)?[Kk]"; then + echo would rm empty backup $b >&2 + set -x + mv "$b" "${b%/*}/.${b##*/}" + set +x + continue + fi + echo restoring $b >&2 if psql $DATABASE_URL < "$b"; then break fi - fi + fi done service postgresql start