9 Commits

Author SHA1 Message Date
Bel LaPointe
7e8ac6bbd1 rm 2022-03-18 11:49:30 -06:00
Bel LaPointe
3cca493648 up mini 2022-03-18 11:34:17 -06:00
Bel LaPointe
54ab5919e2 hopefully better 2021-02-28 13:26:42 -06:00
Bel LaPointe
3ac73e6d28 miniflux v bump 2021-02-24 09:44:19 -06:00
Bel LaPointe
b2cfba373e hopefully fix bad backups 2020-12-06 20:04:35 -07:00
bel
9182e656bf restart on fail, clear old backups 2020-12-05 11:36:36 -07:00
Bel LaPointe
16b974afd1 dont del big backups 2020-09-29 13:35:51 -06:00
Bel LaPointe
604b803f74 hopefully fix restore again 2020-05-29 08:02:26 -06:00
Bel LaPointe
ab0944cbff restore doesnt need decimals 2020-05-29 07:32:26 -06:00
9 changed files with 66 additions and 5456 deletions

View File

@@ -16,7 +16,7 @@ RUN export DEBIAN_FRONTEND=noninteractive; \
cron \ cron \
postgresql postgresql-contrib \ postgresql postgresql-contrib \
&& curl -L \ && curl -L \
https://github.com/miniflux/miniflux/releases/download/2.0.19/miniflux_2.0.19_amd64.deb \ https://github.com/miniflux/miniflux/releases/download/2.0.36/miniflux_2.0.36_amd64.deb \
> /miniflux.deb \ > /miniflux.deb \
&& dpkg -i /miniflux.deb \ && dpkg -i /miniflux.deb \
&& mkdir -p /mnt/save && mkdir -p /mnt/save
@@ -41,6 +41,7 @@ ENV CREATE_ADMIN=0
COPY --from=builder /pause/pauser /pauser COPY --from=builder /pause/pauser /pauser
COPY backup.sh / COPY backup.sh /
COPY restore.sh / COPY restore.sh /
COPY entrypoint.sh /
USER root USER root
### CRON BACKUPS ### CRON BACKUPS
@@ -50,11 +51,4 @@ RUN true \
&& chmod 0644 /etc/cron.d/backups \ && chmod 0644 /etc/cron.d/backups \
&& touch /var/log/cronj.log && touch /var/log/cronj.log
ENTRYPOINT \ ENTRYPOINT bash /entrypoint.sh
service postgresql start \
&& until psql $DATABASE_URL < /dev/null; do sleep 5; done \
&& bash /restore.sh \
&& miniflux -migrate \
&& miniflux -create-admin \
&& miniflux \
& exec /pauser

View File

@@ -1,12 +1,16 @@
b=$(date +%Y%m%d%H%M%S) b=$(date +%Y%m%d%H%M%S)
mkdir -p /mnt/save/$b mkdir -p /mnt/save/$b
pg_dump $DATABASE_URL --clean > /mnt/save/$b/pg.dump \ (
set -e
pg_dump $DATABASE_URL --clean > /mnt/save/$b/.pg.dump
mv /mnt/save/$b/{.,""}pg.dump
) \
|| ( || (
rm -rf /mnt/save/$b rm -rf /mnt/save/$b
echo "backup failed; deleting $b" echo "backup failed; deleting $b"
exit 1 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 rm -rf /mnt/save/$b
echo rm empty backup $b echo rm empty backup $b
fi fi

38
entrypoint.sh Executable file
View File

@@ -0,0 +1,38 @@
#! /bin/bash
LOG=/tmp/bel.log
main() {
echo "" > $LOG
ensure start_postgres
until psql $DATABASE_URL < /dev/null; do sleep 5; done
bash /restore.sh
miniflux -migrate
miniflux -create-admin
ensure miniflux
exec /pauser
}
start_postgres() {
service postgresql start
psql $DATABASE_URL
}
ensure() {
_ensure "$@" &>> $LOG & disown
}
_ensure() {
while true; do
echo $(date): ensuring "$@" >&2
"$@"
sleep 3
done
}
main "$@"

View File

@@ -1,6 +1,20 @@
for b in $(find /mnt/save -type f | sort | tail -n 1); 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
rm -f ${all_backups[i]} || true
done
for b in "${all_backups[@]}"; do
if [ -n "$b" ]; then if [ -n "$b" ]; then
echo restoring $b du -sh "$b"
if ! du -sh "$b" | grep -Ei "^[ \t]*[0-9][0-9]*[0-9]?(.0)?[mg]"; 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 if psql $DATABASE_URL < "$b"; then
break break
fi fi

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long