Mirror the restic system-config adapters for the other two engines, each in that engine's own convention, so system backup/restore/status/retention work on any location regardless of engine: - kopia: BackupSystemToLocation (--tags system:config), SystemSnapshotsJson (filter tag system:config), RestoreSystemLatest, ForgetSystem (per-source policy on $configs_dir + maintenance). - borg: BackupSystemToLocation (archive system-<host>-<ts>, comment system=config; no app is named "system" so the namespace can't collide), SystemSnapshotsJson (--glob-archives system-<host>-*), RestoreSystemLatest, ForgetSystem (prune the system-<host>-* glob). No dispatcher change needed — engineBackupSystem/SystemSnapshotsJson/ RestoreSystemLatest/ForgetSystem already resolve <engine><fn> per location. All three engines now define the full set; syntax clean. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Signed-off-by: librelad <librelad@digitalangels.vip>
79 lines
2.7 KiB
Bash
79 lines
2.7 KiB
Bash
#!/bin/bash
|
|
|
|
borgForgetApp()
|
|
{
|
|
local idx="$1"
|
|
local app_name="$2"
|
|
|
|
if resticLocationAppendOnly "$idx"; then
|
|
isNotice "$(resticLocationName "$idx") is append-only — skipping forget for $app_name"
|
|
return 0
|
|
fi
|
|
|
|
local keep_last keep_daily keep_weekly keep_monthly keep_yearly
|
|
keep_last=$(resticRetentionFor "$idx" KEEP_LAST)
|
|
keep_daily=$(resticRetentionFor "$idx" KEEP_DAILY)
|
|
keep_weekly=$(resticRetentionFor "$idx" KEEP_WEEKLY)
|
|
keep_monthly=$(resticRetentionFor "$idx" KEEP_MONTHLY)
|
|
keep_yearly=$(resticRetentionFor "$idx" KEEP_YEARLY)
|
|
|
|
borgEnvExport "$idx" || return 1
|
|
|
|
local host_tag="${CFG_INSTALL_NAME:-libreportal}"
|
|
local args=(prune --glob-archives "${app_name}-${host_tag}-*")
|
|
[[ -n "$keep_last" ]] && args+=(--keep-last "$keep_last")
|
|
[[ -n "$keep_daily" ]] && args+=(--keep-daily "$keep_daily")
|
|
[[ -n "$keep_weekly" ]] && args+=(--keep-weekly "$keep_weekly")
|
|
[[ -n "$keep_monthly" ]] && args+=(--keep-monthly "$keep_monthly")
|
|
[[ -n "$keep_yearly" ]] && args+=(--keep-yearly "$keep_yearly")
|
|
|
|
isNotice "Applying retention for $app_name on $(resticLocationName "$idx")"
|
|
runBackupOp borg "${args[@]}"
|
|
local rc=$?
|
|
|
|
if [[ "$CFG_BACKUP_PRUNE_AFTER_FORGET" == "true" && $rc -eq 0 ]]; then
|
|
runBackupOp borg compact
|
|
fi
|
|
|
|
borgEnvUnset
|
|
return $rc
|
|
}
|
|
|
|
borgForgetSystem()
|
|
{
|
|
local idx="$1"
|
|
|
|
if resticLocationAppendOnly "$idx"; then
|
|
isNotice "$(resticLocationName "$idx") is append-only — skipping forget for system config"
|
|
return 0
|
|
fi
|
|
|
|
local keep_last keep_daily keep_weekly keep_monthly keep_yearly
|
|
keep_last=$(resticRetentionFor "$idx" KEEP_LAST)
|
|
keep_daily=$(resticRetentionFor "$idx" KEEP_DAILY)
|
|
keep_weekly=$(resticRetentionFor "$idx" KEEP_WEEKLY)
|
|
keep_monthly=$(resticRetentionFor "$idx" KEEP_MONTHLY)
|
|
keep_yearly=$(resticRetentionFor "$idx" KEEP_YEARLY)
|
|
|
|
borgEnvExport "$idx" || return 1
|
|
|
|
local host_tag="${CFG_INSTALL_NAME:-libreportal}"
|
|
local args=(prune --glob-archives "system-${host_tag}-*")
|
|
[[ -n "$keep_last" ]] && args+=(--keep-last "$keep_last")
|
|
[[ -n "$keep_daily" ]] && args+=(--keep-daily "$keep_daily")
|
|
[[ -n "$keep_weekly" ]] && args+=(--keep-weekly "$keep_weekly")
|
|
[[ -n "$keep_monthly" ]] && args+=(--keep-monthly "$keep_monthly")
|
|
[[ -n "$keep_yearly" ]] && args+=(--keep-yearly "$keep_yearly")
|
|
|
|
isNotice "Applying retention for system config on $(resticLocationName "$idx")"
|
|
runBackupOp borg "${args[@]}"
|
|
local rc=$?
|
|
|
|
if [[ "$CFG_BACKUP_PRUNE_AFTER_FORGET" == "true" && $rc -eq 0 ]]; then
|
|
runBackupOp borg compact
|
|
fi
|
|
|
|
borgEnvUnset
|
|
return $rc
|
|
}
|