Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automized deletion of old db_dumps #15

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions backup/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ RUN apk add postgresql-client
RUN apk add dcron

COPY pgsqlbackup.sh /usr/local/bin/pgsqlbackup.sh
COPY drop_old_dumps.sh /usr/local/bin/drop_old_dumps.sh

ENV DB_NAME="b2share"
ENV DB_HOST="postgres"
ENV DB_PORT="5432"
ENV NUMBER_OF_DUMPS="30"

# Create cron job
COPY crontab /etc/cron.d/pgsqlbackup-cron
Expand Down
1 change: 1 addition & 0 deletions backup/crontab
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
0 1 * * * /bin/sh /usr/local/bin/pgsqlbackup.sh 2>&1
0 2 * * * /bin/sh /usr/local/bin/drop_old_dumps.sh 2>&1
6 changes: 6 additions & 0 deletions backup/drop_old_dumps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
#
# Drop old database dumps.

/usr/bin/find /usr/local/share/pgsql_dumps -type f -mtime +${NUMBER_OF_DUMPS} -delete

1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ services:
# environment:
# - "PGPASSWORD=${B2SHARE_POSTGRESQL_PASSWORD}"
# - "POSTGRES_USER=${B2SHARE_POSTGRESQL_USER}"
# - "NUMBER_OF_DUMPS=30"
# volumes:
# - "${B2SHARE_DATADIR}/db_dump:/usr/local/share/pgsql_dumps"