mirror of
https://github.com/kopia/kopia.git
synced 2026-01-29 00:33:24 -05:00
added SaveSnapshot() to snapshot.Manifest
This commit is contained in:
@@ -119,7 +119,7 @@ func runBackupCommand(c *kingpin.ParseContext) error {
|
||||
manifest.Handle = handleID
|
||||
manifest.Description = *backupDescription
|
||||
|
||||
err = saveBackupManifest(conn.Vault, fileID, manifest)
|
||||
err = conn.SnapshotManager.SaveSnapshot(fileID, manifest)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot save manifest: %v", err)
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/kopia/kopia/snapshot"
|
||||
"github.com/kopia/kopia/vault"
|
||||
)
|
||||
|
||||
func saveBackupManifest(vlt *vault.Vault, manifestID string, m *snapshot.Manifest) error {
|
||||
b, err := json.Marshal(m)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot marshal backup manifest to JSON: %v", err)
|
||||
}
|
||||
|
||||
return vlt.Put(manifestID, b)
|
||||
}
|
||||
@@ -74,6 +74,16 @@ func (m *Manager) LoadSnapshot(manifestID string) (*Manifest, error) {
|
||||
return &s, nil
|
||||
}
|
||||
|
||||
// SaveSnapshot persists given snapshot manifest with a given ID.
|
||||
func (m *Manager) SaveSnapshot(manifestID string, manifest *Manifest) error {
|
||||
b, err := json.Marshal(manifest)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot marshal backup manifest to JSON: %v", err)
|
||||
}
|
||||
|
||||
return m.vault.Put(manifestID, b)
|
||||
}
|
||||
|
||||
// LoadSnapshots efficiently loads and parses a given list of snapshot IDs.
|
||||
func (m *Manager) LoadSnapshots(names []string) ([]*Manifest, error) {
|
||||
result := make([]*Manifest, len(names))
|
||||
|
||||
Reference in New Issue
Block a user