Skip to content

Commit dfbc326

Browse files
committed
Create an image for db backups
1 parent 901a42d commit dfbc326

File tree

5 files changed

+29
-1
lines changed

5 files changed

+29
-1
lines changed

.github/workflows/sb-server.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ jobs:
2020
with:
2121
name: "rsync-host"
2222
username: "ajayyy"
23-
folder: "./rsync"
23+
folder: "./containers/rsync"
24+
secrets:
25+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
backup-db:
27+
uses: ./.github/workflows/docker-build.yml
28+
with:
29+
name: "db-backup"
30+
username: "ajayyy"
31+
folder: "./containers/backup-db"
2432
secrets:
2533
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

containers/backup-db/Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM alpine
2+
RUN apk add postgresql-client
3+
RUN apk add restic --repository http://dl-cdn.alpinelinux.org/alpine/latest-stable/community/
4+
5+
COPY ./backup.sh /usr/src/app/backup.sh
6+
RUN chmod +x /usr/src/app/backup.sh
7+
COPY ./backup.sh /usr/src/app/forget.sh
8+
RUN chmod +x /usr/src/app/forget.sh
9+
10+
RUN echo '30 * * * * /usr/src/app/backup.sh' >> /etc/crontabs/root
11+
RUN echo '10 0 * * 1 /usr/src/app/forget.sh' >> /etc/crontabs/root
12+
13+
CMD crond -l 2 -f

containers/backup-db/backup.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
mkdir ./dump
2+
3+
pg_dump -f ./dump/sponsorTimes.dump sponsorTimes
4+
pg_dump -f ./dump/privateDB.dump privateDB
5+
6+
restic backup ./dump

containers/backup-db/forget.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
restic forget --prune --keep-last 48 --keep-daily 7 --keep-weekly 8
File renamed without changes.

0 commit comments

Comments
 (0)