Add exclude patterns, snapshot prune, and other improvements
- Implement exclude patterns with anchored pattern support: - Patterns starting with / only match from root of source dir - Unanchored patterns match anywhere in path - Support for glob patterns (*.log, .*, **/*.pack) - Directory patterns skip entire subtrees - Add gobwas/glob dependency for pattern matching - Add 16 comprehensive tests for exclude functionality - Add snapshot prune command to clean orphaned data: - Removes incomplete snapshots from database - Cleans orphaned files, chunks, and blobs - Runs automatically at backup start for consistency - Add snapshot remove command for deleting snapshots - Add VAULTIK_AGE_SECRET_KEY environment variable support - Fix duplicate fx module provider in restore command - Change snapshot ID format to hostname_YYYY-MM-DDTHH:MM:SSZ
This commit is contained in:
1 parent
05286bed01
commit
2afd54d693
23 files changed
+1769
-98
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package vaultik
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -122,3 +123,34 @@ func (v *Vaultik) GetDecryptor() (*crypto.Decryptor, error) {
|
||||
func (v *Vaultik) GetFilesystem() afero.Fs {
|
||||
return v.Fs
|
||||
}
|
||||
|
||||
// TestVaultik wraps a Vaultik with captured stdout/stderr for testing
|
||||
type TestVaultik struct {
|
||||
*Vaultik
|
||||
Stdout *bytes.Buffer
|
||||
Stderr *bytes.Buffer
|
||||
Stdin *bytes.Buffer
|
||||
}
|
||||
|
||||
// NewForTesting creates a minimal Vaultik instance for testing purposes.
|
||||
// Only the Storage field is populated; other fields are nil.
|
||||
// Returns a TestVaultik that captures stdout/stderr in buffers.
|
||||
func NewForTesting(storage storage.Storer) *TestVaultik {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
stdout := &bytes.Buffer{}
|
||||
stderr := &bytes.Buffer{}
|
||||
stdin := &bytes.Buffer{}
|
||||
return &TestVaultik{
|
||||
Vaultik: &Vaultik{
|
||||
Storage: storage,
|
||||
ctx: ctx,
|
||||
cancel: cancel,
|
||||
Stdout: stdout,
|
||||
Stderr: stderr,
|
||||
Stdin: stdin,
|
||||
},
|
||||
Stdout: stdout,
|
||||
Stderr: stderr,
|
||||
Stdin: stdin,
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user