mirror of
https://github.com/allaunthefox/Research-Stack.git
synced 2026-07-31 03:05:21 +00:00
Fix Porkbun DNS, automate postgres backups, fix rds_probe vulns
- Porkbun API keys verified working (SUCCESS ping) - Automated daily AppFlowy postgres backups via systemd timer - rds_probe: switch from rustls to native-tls (fixes 3 Dependabot alerts) - ec2-config.nix: add appflowy-backup service and timer
This commit is contained in:
parent
390116d2f4
commit
28d02223a6
3 changed files with 50 additions and 1 deletions
28
4-Infrastructure/infra/backup-appflowy-db.sh
Normal file
28
4-Infrastructure/infra/backup-appflowy-db.sh
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#!/run/current-system/sw/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
BACKUP_DIR="${1:-/var/lib/backups/appflowy}"
|
||||
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
|
||||
mkdir -p "${BACKUP_DIR}" 2>/dev/null || true
|
||||
|
||||
PODMAN="/run/current-system/sw/bin/podman"
|
||||
PGDUMP="/usr/lib/postgresql/16/bin/pg_dump"
|
||||
CAT="/run/current-system/sw/bin/cat"
|
||||
GREP="/run/current-system/sw/bin/grep"
|
||||
GZIP="/run/current-system/sw/bin/gzip"
|
||||
WC="/run/current-system/sw/bin/wc"
|
||||
RM="/run/current-system/sw/bin/rm"
|
||||
LS="/run/current-system/sw/bin/ls"
|
||||
XARGS="/run/current-system/sw/bin/xargs"
|
||||
|
||||
echo "Backing up AppFlowy postgres to ${BACKUP_DIR}..."
|
||||
$PODMAN exec appflowy-cloud_postgres_1 $PGDUMP \
|
||||
-U postgres -d appflowy 2>/dev/null | \
|
||||
$GREP -v '^\\restrict \|^\\unrestrict ' > "${BACKUP_DIR}/appflowy-${TIMESTAMP}.sql"
|
||||
|
||||
BYTES=$($WC -c < "${BACKUP_DIR}/appflowy-${TIMESTAMP}.sql")
|
||||
echo "Saved: ${BACKUP_DIR}/appflowy-${TIMESTAMP}.sql (${BYTES} bytes)"
|
||||
$GZIP -f "${BACKUP_DIR}/appflowy-${TIMESTAMP}.sql"
|
||||
$LS -lh "${BACKUP_DIR}/appflowy-${TIMESTAMP}.sql.gz"
|
||||
|
||||
$LS -t "${BACKUP_DIR}/appflowy-"*.sql.gz 2>/dev/null | $XARGS -r $RM 2>/dev/null; true
|
||||
|
|
@ -121,4 +121,25 @@
|
|||
ExecStop = "${pkgs.podman-compose}/bin/podman-compose -f docker-compose.minimal.yml down";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services.appflowy-backup = {
|
||||
description = "Daily AppFlowy PostgreSQL backup";
|
||||
after = [ "network-online.target" ];
|
||||
wants = [ "network-online.target" ];
|
||||
path = with pkgs; [ podman ];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = "/var/lib/scripts/backup-appflowy-db.sh";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.timers.appflowy-backup = {
|
||||
description = "Daily AppFlowy backup timer";
|
||||
requires = [ "appflowy-backup.service" ];
|
||||
timerConfig = {
|
||||
OnCalendar = "daily";
|
||||
Persistent = true;
|
||||
};
|
||||
wantedBy = [ "timers.target" ];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ license = "MIT"
|
|||
authors = ["Research Stack"]
|
||||
|
||||
[dependencies]
|
||||
sqlx = { version = "0.7", features = ["runtime-tokio-rustls", "postgres", "json", "uuid"] }
|
||||
sqlx = { version = "0.7", features = ["runtime-tokio-native-tls", "postgres", "json", "uuid"] }
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
dotenv = "0.15"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue