mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-04 15:26:48 +00:00
Merge pull request #244 from mouse-reeve/cron
Adds database backup crontab
This commit is contained in:
commit
9c68b6d430
4 changed files with 18 additions and 1 deletions
|
@ -24,10 +24,11 @@ services:
|
||||||
- ./certbot/logs:/var/log/letsencrypt
|
- ./certbot/logs:/var/log/letsencrypt
|
||||||
- ./certbot/data:/var/www/certbot
|
- ./certbot/data:/var/www/certbot
|
||||||
db:
|
db:
|
||||||
image: postgres
|
build: postgres-docker
|
||||||
env_file: .env
|
env_file: .env
|
||||||
volumes:
|
volumes:
|
||||||
- pgdata:/var/lib/postgresql/data
|
- pgdata:/var/lib/postgresql/data
|
||||||
|
- backups:/backups
|
||||||
networks:
|
networks:
|
||||||
- main
|
- main
|
||||||
web:
|
web:
|
||||||
|
@ -71,6 +72,7 @@ services:
|
||||||
restart: on-failure
|
restart: on-failure
|
||||||
volumes:
|
volumes:
|
||||||
pgdata:
|
pgdata:
|
||||||
|
backups:
|
||||||
static_volume:
|
static_volume:
|
||||||
media_volume:
|
media_volume:
|
||||||
networks:
|
networks:
|
||||||
|
|
10
postgres-docker/Dockerfile
Normal file
10
postgres-docker/Dockerfile
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
FROM postgres:latest
|
||||||
|
|
||||||
|
# crontab
|
||||||
|
RUN mkdir /backups
|
||||||
|
COPY ./backup.sh /backups
|
||||||
|
COPY ./cronfile /etc/cron.d/cronfile
|
||||||
|
RUN apt-get update && apt-get -y install cron
|
||||||
|
RUN chmod 0644 /etc/cron.d/cronfile
|
||||||
|
RUN crontab /etc/cron.d/cronfile
|
||||||
|
RUN touch /var/log/cron.log
|
3
postgres-docker/backup.sh
Executable file
3
postgres-docker/backup.sh
Executable file
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/bash
|
||||||
|
filename=backup__$(date +%F)
|
||||||
|
pg_dump -U fedireads > /backups/$filename.sql
|
2
postgres-docker/cronfile
Normal file
2
postgres-docker/cronfile
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
0 0 * * * /backups/db_bashup.sh
|
||||||
|
|
Loading…
Reference in a new issue