Check --keep-newer-than before the backup starts (closes #307)
check / check (push) Waiting to run
check / check (push) Waiting to run
snapshot create read --keep-newer-than only in the post-backup prune, so a value the duration parser rejects failed the run after the snapshot was uploaded: a nightly cron line added a snapshot each night, reported it as failed, and never deleted any. Without --prune the flag was ignored. The command now checks the flag before it starts and fails on an invalid duration or a missing --prune. A failed post-backup prune is now wrapped in ErrPostBackupPruneFailed and reported as "Backup completed, but post-backup prune failed: ..." rather than as a failed snapshot creation. The exit status stays 1. Model: opus-5-5
This commit was merged in pull request #346.
This commit is contained in:
@@ -71,6 +71,11 @@ otherwise from the platform config directory (~/.config/vaultik/config.yml
|
||||
on Linux), then /etc/vaultik/config.yml.`,
|
||||
Args: cobra.ArbitraryArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
err := opts.Validate()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Pass snapshot names from args
|
||||
opts.Snapshots = args
|
||||
// --skip-errors is a global flag on the root command.
|
||||
@@ -97,6 +102,13 @@ on Linux), then /etc/vaultik/config.yml.`,
|
||||
}, func(v *vaultik.Vaultik) error {
|
||||
return v.CreateSnapshot(opts)
|
||||
}, func(err error) {
|
||||
if errors.Is(err, vaultik.ErrPostBackupPruneFailed) {
|
||||
log.Error("Post-backup prune failed", "error", err)
|
||||
ReportErrorf("Backup completed, but %v", err)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
log.Error("Snapshot creation failed", "error", err)
|
||||
ReportErrorf("Snapshot creation failed: %v", err)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user