-
Notifications
You must be signed in to change notification settings - Fork 9
53 lines (48 loc) · 1.89 KB
/
Copy pathdb-backup.yml
File metadata and controls
53 lines (48 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: Database Dump
on:
schedule:
- cron: '0 0 * * 1' # Every Monday at midnight UTC
workflow_dispatch:
jobs:
backup:
timeout-minutes: 120
runs-on: blacksmith-32vcpu-ubuntu-2404
permissions:
contents: write
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: '24'
cache: pnpm
- name: Install dependencies
run: pnpm install --filter @semianalysisai/inferencex-db...
env:
CYPRESS_INSTALL_BINARY: '0'
- name: Dump database
env:
DATABASE_READONLY_URL: ${{ secrets.DATABASE_READONLY_URL }}
run: |
set -euo pipefail
DUMP_DIR="inferencex-dump-$(date -u +%Y-%m-%d)"
pnpm admin:db:dump "$DUMP_DIR"
echo "DUMP_DIR=${DUMP_DIR}" >> "$GITHUB_ENV"
echo "TAG=db-dump/$(date -u +%Y-%m-%d)" >> "$GITHUB_ENV"
- name: Compress and split dump
run: |
set -euo pipefail
( cd packages/db
tar -cf - "$DUMP_DIR" \
| xz -v -T0 --memlimit-compress=99% --lzma2=preset=9e,dict=192MiB \
| split -b 1900m -d -a 2 - "${GITHUB_WORKSPACE}/${DUMP_DIR}.tar.xz.part" )
echo "DUMP_GLOB=${DUMP_DIR}.tar.xz.part*" >> "$GITHUB_ENV"
- name: Create release
env:
GH_TOKEN: ${{ github.token }}
run: |
# $DUMP_GLOB is intentionally unquoted so the shell expands it to every part file.
gh release create "$TAG" $DUMP_GLOB \
--title "DB Dump $(date -u +%Y-%m-%d)" \
--notes 'Weekly full database dump (xz-compressed, split into parts under 2 GiB). Reassemble: `cat *.tar.xz.part* | xz -d | tar -x`' \
--latest=false