add side container which backups tt-rss database once a week

bump alpine image to 3.12
legacy-php5
Andrew Dolgov 4 years ago
parent 328984f153
commit 707b79b52f

@ -15,6 +15,7 @@ General outline of the configuration is as follows:
- Caddy has its http port exposed to the outside - Caddy has its http port exposed to the outside
- optional SSL support via Caddy w/ automatic letsencrypt certificates - optional SSL support via Caddy w/ automatic letsencrypt certificates
- feed updates are handled via update daemon started in a separate container (updater) - feed updates are handled via update daemon started in a separate container (updater)
- optional backups container which performs tt-rss database backup once a week
### Installation ### Installation

@ -1,7 +1,7 @@
FROM alpine:3.9 FROM alpine:3.12
EXPOSE 9000/tcp EXPOSE 9000/tcp
RUN apk add --no-cache php7 php7-fpm \ RUN apk add --no-cache dcron php7 php7-fpm \
php7-pdo php7-gd php7-pgsql php7-pdo_pgsql php7-mbstring \ php7-pdo php7-gd php7-pgsql php7-pdo_pgsql php7-mbstring \
php7-intl php7-xml php7-curl php7-session \ php7-intl php7-xml php7-curl php7-session \
php7-dom php7-fileinfo php7-json \ php7-dom php7-fileinfo php7-json \
@ -11,6 +11,8 @@ RUN apk add --no-cache php7 php7-fpm \
ADD startup.sh / ADD startup.sh /
ADD updater.sh / ADD updater.sh /
ADD index.php / ADD index.php /
ADD dcron.sh /
ADD backup-database.sh /etc/periodic/weekly/backup-database
RUN sed -i.bak 's/^listen = 127.0.0.1:9000/listen = 9000/' /etc/php7/php-fpm.d/www.conf RUN sed -i.bak 's/^listen = 127.0.0.1:9000/listen = 9000/' /etc/php7/php-fpm.d/www.conf
RUN sed -i.bak 's/\(memory_limit =\) 128M/\1 256M/' /etc/php7/php.ini RUN sed -i.bak 's/\(memory_limit =\) 128M/\1 256M/' /etc/php7/php.ini

@ -0,0 +1,22 @@
#!/bin/sh -e
DST_DIR=/backups
KEEP_DAYS=28
if pg_isready -h $DB_HOST -U $DB_USER; then
DST_FILE=ttrss-backup-$(date +%Y%m%d).sql.gz
echo backing up tt-rss database to $DST_DIR/$DST_FILE...
export PGPASSWORD=$DB_PASS
pg_dump --clean -h $DB_HOST -U $DB_USER $DB_NAME | gzip > $DST_DIR/$DST_FILE
echo cleaning up...
find $DST_DIR -type f -name '*.sql.gz' -mtime +$KEEP_DAYS -delete
echo done.
else
echo backup failed: database is not ready.
fi

@ -0,0 +1,5 @@
#!/bin/sh
# https://github.com/dubiousjim/dcron/issues/13
set -e
/usr/sbin/crond "$@"

@ -32,6 +32,25 @@ services:
depends_on: depends_on:
- db - db
backups:
build:
context:
./app
restart: unless-stopped
environment:
- DB_TYPE=pgsql
- DB_HOST=db
- DB_NAME=${POSTGRES_USER}
- DB_USER=${POSTGRES_USER}
- DB_PASS=${POSTGRES_PASSWORD}
- OWNER_UID=${OWNER_UID}
- OWNER_GID=${OWNER_GID}
volumes:
- backups:/backups
depends_on:
- db
command: /dcron.sh -f
updater: updater:
build: build:
context: context:
@ -91,3 +110,4 @@ volumes:
db: db:
app: app:
certs: certs:
backups:

Loading…
Cancel
Save