miniflux/backup.sh

17 lines
354 B
Bash
Executable File

b=$(date +%Y%m%d%H%M%S)
mkdir -p /mnt/save/$b
(
set -e
pg_dump $DATABASE_URL --clean > /mnt/save/$b/.pg.dump
mv /mnt/save/$b/{.,""}pg.dump
) \
|| (
rm -rf /mnt/save/$b
echo "backup failed; deleting $b"
exit 1
)
if du -sh /mnt/save/$b | grep -Ei "^[ ]*(4|2.).0K"; then
rm -rf /mnt/save/$b
echo rm empty backup $b
fi