Skip to content

Commit bbb80ee

Browse files
committed
feat: add backup
1 parent 2079192 commit bbb80ee

File tree

9 files changed

+32
-5424
lines changed

9 files changed

+32
-5424
lines changed

.github/workflows/backup.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# generate backup github action
2+
3+
name: Backup PG
4+
5+
on:
6+
workflow_dispatch:
7+
schedule:
8+
- cron: '0 0 * * *'
9+
10+
jobs:
11+
backup:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: backup
16+
run: |
17+
sudo apt-get update
18+
sudo apt-get install postgresql-client
19+
DATE=`date +%Y-%m-%d`
20+
FILENAME=backup-$DATE
21+
pg_dump -U ${{ secrets.POSTGRES_USER }} -h ${{ secrets.POSTGRES_HOST }} -p ${{ secrets.POSTGRES_PORT }} -W -F t ${{ secrets.POSTGRES_DB }} > data/$FILENAME
22+
23+
- name: Commit files
24+
run: |
25+
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
26+
git config --local user.name "github-actions[bot]"
27+
git commit -m "backup PG db" -a || true
28+
- name: Push changes
29+
uses: tianheg/github-actions@push
30+
with:
31+
github_token: ${{ secrets.GITHUB_TOKEN }}
32+
branch: ${{ github.ref }}

data/books.js

Lines changed: 0 additions & 326 deletions
This file was deleted.

0 commit comments

Comments
 (0)