Skip to content

Commit 86ee164

Browse files
committed
fix: further improve db backup
1 parent 4736405 commit 86ee164

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

.github/workflows/db-backup.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,23 @@ jobs:
2929
run: |
3030
set -euo pipefail
3131
DUMP_DIR="inferencex-dump-$(date -u +%Y-%m-%d)"
32+
( s=0; while sleep 30; do s=$((s + 30)); sz=$(du -sh "packages/db/$DUMP_DIR" 2>/dev/null | cut -f1); printf ' [dump] running %dm%02ds, %s written...\n' $((s / 60)) $((s % 60)) "${sz:-0B}"; done ) &
33+
trap 'kill %1 2>/dev/null || true' EXIT
3234
pnpm admin:db:dump "$DUMP_DIR"
33-
# Keep every table intact: tar the dump, compress with xz/lzma2, and split into
34-
# <2 GiB parts to stay under GitHub's per-release-asset cap (even as data grows).
35+
echo "DUMP_DIR=${DUMP_DIR}" >> "$GITHUB_ENV"
36+
echo "TAG=db-dump/$(date -u +%Y-%m-%d)" >> "$GITHUB_ENV"
37+
38+
- name: Compress and split dump
39+
run: |
40+
set -euo pipefail
41+
( s=0; while sleep 30; do s=$((s + 30)); sz=$(du -ch "${GITHUB_WORKSPACE}/${DUMP_DIR}".tar.xz.part* 2>/dev/null | tail -1 | cut -f1); printf ' [compress] running %dm%02ds, %s written...\n' $((s / 60)) $((s % 60)) "${sz:-0B}"; done ) &
42+
trap 'kill %1 2>/dev/null || true' EXIT
3543
( cd packages/db
3644
tar -cf - "$DUMP_DIR" \
37-
| xz -T0 --lzma2=preset=9e,dict=192MiB \
45+
| xz -v -T0 --memlimit-compress=95% --lzma2=preset=9e,dict=192MiB \
3846
| split -b 1900m -d -a 2 - "${GITHUB_WORKSPACE}/${DUMP_DIR}.tar.xz.part" )
3947
echo "DUMP_GLOB=${DUMP_DIR}.tar.xz.part*" >> "$GITHUB_ENV"
40-
echo "TAG=db-dump/$(date -u +%Y-%m-%d)" >> "$GITHUB_ENV"
48+
4149
- name: Create release
4250
env:
4351
GH_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)