Gets database cron into the right image

This commit is contained in:
Mouse Reeve 2020-10-28 15:56:25 -07:00
parent 8b061d63a8
commit 687ff5a6d7
7 changed files with 18 additions and 14 deletions

View file

@ -8,12 +8,3 @@ COPY requirements.txt /app/
RUN pip install -r requirements.txt
COPY ./bookwyrm /app
COPY ./celerywyrm /app
# crontab
COPY ./db_backup.sh /app
RUN apt-get update && apt-get -y install cron
COPY db-backups-cron /etc/cron.d/db-backups-cron
RUN chmod 0644 /etc/cron.d/db-backups-cron
RUN crontab /etc/cron.d/db-backups-cron
RUN touch /var/log/cron.log
CMD cron && tail -f /var/log/cron.log

View file

@ -1 +0,0 @@
0 0 * * * /app/db_bashup.sh

View file

@ -1,3 +0,0 @@
#!/bin/bash
filename=backup__$(date +%F)
pg_dump -U fedireads | gzip > $filename.gz

View file

@ -14,10 +14,11 @@ services:
- static_volume:/app/static
- media_volume:/app/images
db:
image: postgres
build: postgres-docker
env_file: .env
volumes:
- pgdata:/var/lib/postgresql/data
- backups:/backups
networks:
- main
web:
@ -58,6 +59,7 @@ services:
restart: on-failure
volumes:
pgdata:
backups:
static_volume:
media_volume:
networks:

View file

@ -0,0 +1,10 @@
FROM postgres:latest
# crontab
RUN mkdir /backups
COPY ./db_backup.sh /backups
COPY ./db-backups-cron /etc/cron.d/db-backups-cron
RUN apt-get update && apt-get -y install cron
RUN chmod 0644 /etc/cron.d/db-backups-cron
RUN crontab /etc/cron.d/db-backups-cron
RUN touch /var/log/cron.log

View file

@ -0,0 +1,2 @@
0 0 * * * /backups/db_bashup.sh

3
postgres-docker/db_backup.sh Executable file
View file

@ -0,0 +1,3 @@
#!/bin/bash
filename=backup__$(date +%F)
pg_dump -U fedireads > $filename.sql