check / check (push) Waiting to run
A blob is written whole to a temporary file and uploaded once finished, not streamed to storage. The README, ARCHITECTURE.md and config.example.yml now say a backup needs free temporary space for each blob (twice that for an rclone destination that cannot stream uploads) and for the metadata export's copies of the local index, in $TMPDIR, or partly in /var/tmp when TMPDIR is unset. Also corrected: the snapshot ID format, what restore reads and how incomplete snapshots are removed in docs/DATAMODEL.md, what source_path holds, the index_path default, the config search order in the snapshot create help, what snapshot remove cleans up in the prune help, how the release installs Go, and the script/release and script/fmt-check comments. Model: opus-5-5
64 lines
1.9 KiB
Go
64 lines
1.9 KiB
Go
package cli
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
"sneak.berlin/go/vaultik/internal/log"
|
|
"sneak.berlin/go/vaultik/internal/vaultik"
|
|
)
|
|
|
|
// NewPruneCommand creates the prune command
|
|
func NewPruneCommand() *cobra.Command {
|
|
opts := &vaultik.PruneOptions{}
|
|
|
|
cmd := &cobra.Command{
|
|
Use: "prune",
|
|
Short: "Tidy local database and remote storage",
|
|
Long: `Removes orphaned data from both the local index database and
|
|
unreferenced blobs from the backup destination store.
|
|
|
|
Local cleanup drops incomplete snapshots and any files, chunks, or
|
|
blobs no longer referenced by a completed snapshot. Remote cleanup
|
|
scans every snapshot manifest in the destination store, builds the
|
|
set of still-referenced blob hashes, and deletes any blob not in that
|
|
set.
|
|
|
|
Snapshot create --prune runs the same cleanup automatically; this
|
|
command is the manual entry point for the same work (e.g. after a
|
|
crashed backup or to reclaim storage). Snapshot remove leaves blobs in
|
|
place; run this command afterwards to delete the ones no longer
|
|
referenced.`,
|
|
Args: cobra.NoArgs,
|
|
RunE: func(cmd *cobra.Command, _ []string) error {
|
|
// Use unified config resolution
|
|
configPath, err := ResolveConfigPath()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// Use the app framework like other commands
|
|
rootFlags := GetRootFlags()
|
|
|
|
return RunOperation(cmd.Context(), AppOptions{
|
|
ConfigPath: configPath,
|
|
LogOptions: log.Options{
|
|
Verbose: rootFlags.Verbose,
|
|
Debug: rootFlags.Debug,
|
|
Quiet: rootFlags.Quiet,
|
|
JSON: opts.JSON,
|
|
},
|
|
Mode: mutating,
|
|
}, func(v *vaultik.Vaultik) error {
|
|
return v.Prune(opts)
|
|
}, func(err error) {
|
|
log.Error("Prune operation failed", "error", err)
|
|
ReportErrorf("Prune failed: %v", err)
|
|
})
|
|
},
|
|
}
|
|
|
|
cmd.Flags().BoolVar(&opts.Force, "force", false, "Skip confirmation prompt")
|
|
cmd.Flags().BoolVar(&opts.JSON, "json", false, "Output pruning stats as JSON")
|
|
|
|
return cmd
|
|
}
|