/** Pure functions returning SshCommand values — no I/O. */
import { raw } from "../utils/sshCommand.js";
const COOLIFY_COMPOSE = "cd /data/coolify/source && docker compose -f docker-compose.yml -f docker-compose.prod.yml";
// ─── Coolify Backup Commands ─────────────────────────────────────────────────
export function buildPgDumpCommand() {
    return raw("set -o pipefail && docker exec coolify-db pg_dump -U coolify -d coolify | gzip > /tmp/coolify-backup.sql.gz");
}
export function buildConfigTarCommand() {
    return raw("tar czf /tmp/coolify-config.tar.gz -C /data/coolify/source .env docker-compose.yml docker-compose.prod.yml 2>/dev/null || tar czf /tmp/coolify-config.tar.gz -C /data/coolify/source .env docker-compose.yml");
}
export function buildCleanupCommand() {
    return raw("rm -f /tmp/coolify-backup.sql.gz /tmp/coolify-config.tar.gz");
}
export function buildCoolifyVersionCommand() {
    return raw("docker inspect coolify --format '{{.Config.Image}}' 2>/dev/null | sed 's/.*://' || echo unknown");
}
// ─── Coolify Restore Commands ────────────────────────────────────────────────
export function buildStopCoolifyCommand() {
    return raw(`${COOLIFY_COMPOSE} stop`);
}
export function buildStartCoolifyCommand() {
    return raw(`${COOLIFY_COMPOSE} up -d`);
}
export function buildStartDbCommand() {
    return raw(`${COOLIFY_COMPOSE} up -d postgres && sleep 3`);
}
export function buildRestoreDbCommand() {
    return raw("gunzip -c /tmp/coolify-backup.sql.gz | docker exec -i coolify-db psql -U coolify -d coolify");
}
export function buildRestoreConfigCommand() {
    return raw("tar xzf /tmp/coolify-config.tar.gz -C /data/coolify/source");
}
// ─── Bare Server Backup Commands ─────────────────────────────────────────────
export function buildBareConfigTarCommand() {
    return raw("tar czf /tmp/bare-config.tar.gz --ignore-failed-read " +
        "-C / " +
        "etc/nginx " +
        "etc/ssh/sshd_config " +
        "etc/ufw " +
        "etc/fail2ban " +
        "etc/crontab " +
        "etc/apt/apt.conf.d/50unattended-upgrades " +
        "2>/dev/null || tar czf /tmp/bare-config.tar.gz --ignore-failed-read -C / etc/ssh/sshd_config");
}
export function buildBareRestoreConfigCommand() {
    return raw("tar xzf /tmp/bare-config.tar.gz -C /");
}
export function buildBareCleanupCommand() {
    return raw("rm -f /tmp/bare-config.tar.gz");
}
//# sourceMappingURL=backup-commands.js.map