Files

18 lines
767 B
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/sh
# 每日 Postgres 备份(由 codex-pg-backup.service 调,timer 每天触发)。
#
# 连接参数只走 CLOUD_DB_* 环境变量(service 的 EnvironmentFile 指向
# /etc/codex-app-server/env,0600 root);密码绝不出现在命令行与日志里。
# 备份目录默认 /var/lib/codex-app-server/backups,轮转只留最近 7 份
# (每天一次 = 一周);备份文件含生产库全量(含 GitHub App 配置),
# 目录 700、service 的 UMask=0077 保证文件 600,绝不要放宽。
set -eu
APP_DIR=${APP_DIR:-/opt/codex-app-server}
BACKUP_DIR=${BACKUP_DIR:-/var/lib/codex-app-server/backups}
mkdir -p "$BACKUP_DIR"
chmod 700 "$BACKUP_DIR"
cd "$APP_DIR"
python3 -m cloud.backup --backend postgres --out "$BACKUP_DIR" --keep 7