mirror of
https://git.tt-rss.org/fox/ttrss-docker-compose
synced 2025-06-13 13:29:54 +02:00
add side container which backups tt-rss database once a week
bump alpine image to 3.12
This commit is contained in:
parent
4b0a057199
commit
b2336cee44
6 changed files with 71 additions and 2 deletions
|
@ -18,6 +18,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
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,23 @@ services:
|
||||||
- app
|
- app
|
||||||
command: /updater.sh
|
command: /updater.sh
|
||||||
|
|
||||||
|
backups:
|
||||||
|
image: cthulhoo/ttrss-fpm-pgsql-static
|
||||||
|
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
|
||||||
|
|
||||||
web:
|
web:
|
||||||
image: cthulhoo/ttrss-web
|
image: cthulhoo/ttrss-web
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
@ -87,3 +104,4 @@ volumes:
|
||||||
db:
|
db:
|
||||||
app:
|
app:
|
||||||
certs:
|
certs:
|
||||||
|
backups:
|
||||||
|
|
|
@ -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 \
|
||||||
|
@ -12,6 +12,8 @@ ADD startup.sh /
|
||||||
ADD updater.sh /
|
ADD updater.sh /
|
||||||
ADD index.php /
|
ADD index.php /
|
||||||
ADD build-prepare.sh /
|
ADD build-prepare.sh /
|
||||||
|
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
|
||||||
|
|
22
src/app/backup-database.sh
Executable file
22
src/app/backup-database.sh
Executable file
|
@ -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
|
5
src/app/dcron.sh
Executable file
5
src/app/dcron.sh
Executable file
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# https://github.com/dubiousjim/dcron/issues/13
|
||||||
|
set -e
|
||||||
|
|
||||||
|
/usr/sbin/crond "$@"
|
|
@ -54,6 +54,26 @@ services:
|
||||||
- app
|
- app
|
||||||
command: /updater.sh
|
command: /updater.sh
|
||||||
|
|
||||||
|
backups:
|
||||||
|
image: cthulhoo/ttrss-fpm-pgsql-static:${BUILD_TAG}
|
||||||
|
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
|
||||||
|
|
||||||
web:
|
web:
|
||||||
image: cthulhoo/ttrss-web:latest
|
image: cthulhoo/ttrss-web:latest
|
||||||
build: ./web
|
build: ./web
|
||||||
|
@ -96,3 +116,4 @@ volumes:
|
||||||
db:
|
db:
|
||||||
app:
|
app:
|
||||||
certs:
|
certs:
|
||||||
|
backups:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue