Compare commits
7 Commits
v1.0.1
...
7e8ac6bbd1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7e8ac6bbd1 | ||
|
|
3cca493648 | ||
|
|
54ab5919e2 | ||
|
|
3ac73e6d28 | ||
|
|
b2cfba373e | ||
|
|
9182e656bf | ||
|
|
16b974afd1 |
12
Dockerfile
12
Dockerfile
@@ -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
|
|
||||||
|
|||||||
10
backup.sh
10
backup.sh
@@ -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|2.).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
38
entrypoint.sh
Executable 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 "$@"
|
||||||
|
|
||||||
10
restore.sh
10
restore.sh
@@ -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
|
if [ -n "$b" ]; then
|
||||||
du -sh "$b"
|
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
|
echo would rm empty backup $b >&2
|
||||||
set -x
|
set -x
|
||||||
mv "$b" "${b%/*}/.${b##*/}"
|
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
Reference in New Issue
Block a user