restore doesnt need decimals

master
Bel LaPointe 2020-05-29 07:32:26 -06:00
parent cf008cd284
commit ab0944cbff
2 changed files with 11 additions and 4 deletions

View File

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

View File

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