Compare commits

...

7 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
9 changed files with 56 additions and 5454 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.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 \
&& dpkg -i /miniflux.deb \
&& mkdir -p /mnt/save
@ -41,6 +41,7 @@ ENV CREATE_ADMIN=0
COPY --from=builder /pause/pauser /pauser
COPY backup.sh /
COPY restore.sh /
COPY entrypoint.sh /
USER root
### CRON BACKUPS
@ -50,11 +51,4 @@ RUN true \
&& chmod 0644 /etc/cron.d/backups \
&& touch /var/log/cronj.log
ENTRYPOINT \
service postgresql start \
&& until psql $DATABASE_URL < /dev/null; do sleep 5; done \
&& bash /restore.sh \
&& miniflux -migrate \
&& miniflux -create-admin \
&& miniflux \
& exec /pauser
ENTRYPOINT bash /entrypoint.sh

View File

@ -1,12 +1,16 @@
b=$(date +%Y%m%d%H%M%S)
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
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

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,7 +1,13 @@
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
rm -f ${all_backups[i]} || true
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)?[mg]"; then
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##*/}"

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