Create an image for db backups

This commit is contained in:
Ajay 2022-05-17 01:29:49 -04:00
parent 901a42d1b4
commit dfbc32617b
5 changed files with 29 additions and 1 deletions

View file

@ -20,6 +20,14 @@ jobs:
with:
name: "rsync-host"
username: "ajayyy"
folder: "./rsync"
folder: "./containers/rsync"
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
backup-db:
uses: ./.github/workflows/docker-build.yml
with:
name: "db-backup"
username: "ajayyy"
folder: "./containers/backup-db"
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View file

@ -0,0 +1,13 @@
FROM alpine
RUN apk add postgresql-client
RUN apk add restic --repository http://dl-cdn.alpinelinux.org/alpine/latest-stable/community/
COPY ./backup.sh /usr/src/app/backup.sh
RUN chmod +x /usr/src/app/backup.sh
COPY ./backup.sh /usr/src/app/forget.sh
RUN chmod +x /usr/src/app/forget.sh
RUN echo '30 * * * * /usr/src/app/backup.sh' >> /etc/crontabs/root
RUN echo '10 0 * * 1 /usr/src/app/forget.sh' >> /etc/crontabs/root
CMD crond -l 2 -f

View file

@ -0,0 +1,6 @@
mkdir ./dump
pg_dump -f ./dump/sponsorTimes.dump sponsorTimes
pg_dump -f ./dump/privateDB.dump privateDB
restic backup ./dump

View file

@ -0,0 +1 @@
restic forget --prune --keep-last 48 --keep-daily 7 --keep-weekly 8