restart on fail, clear old backups

master
bel 2020-12-05 11:36:36 -07:00
parent 16b974afd1
commit 9182e656bf
3 changed files with 10 additions and 5 deletions

View File

@ -16,7 +16,7 @@ RUN export DEBIAN_FRONTEND=noninteractive; \
cron \
postgresql postgresql-contrib \
&& curl -L \
https://github.com/miniflux/miniflux/releases/download/2.0.21/miniflux_2.0.21_amd64.deb \
https://github.com/miniflux/miniflux/releases/download/2.0.25/miniflux_2.0.25_amd64.deb \
> /miniflux.deb \
&& dpkg -i /miniflux.deb \
&& mkdir -p /mnt/save
@ -56,5 +56,5 @@ ENTRYPOINT \
&& bash /restore.sh \
&& miniflux -migrate \
&& miniflux -create-admin \
&& miniflux \
&& (while true; do miniflux; sleep 1; done) \
& exec /pauser

View File

@ -1,12 +1,12 @@
b=$(date +%Y%m%d%H%M%S)
mkdir -p /mnt/save/$b
pg_dump $DATABASE_URL --clean > /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
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,4 +1,9 @@
for b in $(find /mnt/save -not -path '*/\.*' -type f | sort -r); do
all_backups=($(find /mnt/save -not -path '*/\.*' -type f | sort -r))
for ((i=${#all_backups[@]}-1; i>50; i--)); do
echo rm old backpu ${all_backups[i]} >&2
done
for b in "${all_backups[@]}"; do
if [ -n "$b" ]; then
du -sh "$b"
if ! du -sh "$b" | grep -Ei "^[ \t]*[0-9][0-9]*[0-9]?(.0)?[mg]"; then