mirror of
https://github.com/restic/restic.git
synced 2026-04-14 09:08:51 +00:00
Check timestamps for files
This commit is contained in:
@@ -53,11 +53,22 @@ func print_tree2(indent int, t *khepri.Tree) {
|
||||
}
|
||||
|
||||
func commandBackup(be backend.Server, key *khepri.Key, args []string) error {
|
||||
if len(args) != 1 {
|
||||
return errors.New("usage: backup [dir|file]")
|
||||
if len(args) < 1 || len(args) > 2 {
|
||||
return errors.New("usage: backup [dir|file] [snapshot-id]")
|
||||
}
|
||||
|
||||
var parentSnapshotID backend.ID
|
||||
var err error
|
||||
|
||||
target := args[0]
|
||||
if len(args) > 1 {
|
||||
parentSnapshotID, err = backend.FindSnapshot(be, args[1])
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid id %q: %v", args[1], err)
|
||||
}
|
||||
|
||||
fmt.Printf("found parent snapshot %v\n", parentSnapshotID)
|
||||
}
|
||||
|
||||
arch, err := khepri.NewArchiver(be, key)
|
||||
if err != nil {
|
||||
@@ -89,7 +100,7 @@ func commandBackup(be backend.Server, key *khepri.Key, args []string) error {
|
||||
// return true
|
||||
// }
|
||||
|
||||
t, err := arch.LoadTree(target)
|
||||
t, err := arch.LoadTree(target, parentSnapshotID)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
||||
return err
|
||||
@@ -144,7 +155,7 @@ func commandBackup(be backend.Server, key *khepri.Key, args []string) error {
|
||||
}(ch)
|
||||
}
|
||||
|
||||
sn, id, err := arch.Snapshot(target, t)
|
||||
sn, id, err := arch.Snapshot(target, t, parentSnapshotID)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ func errx(code int, format string, data ...interface{}) {
|
||||
|
||||
type commandFunc func(backend.Server, *khepri.Key, []string) error
|
||||
|
||||
var commands map[string]commandFunc
|
||||
var commands = make(map[string]commandFunc)
|
||||
|
||||
func readPassword(env string, prompt string) string {
|
||||
|
||||
@@ -126,7 +126,6 @@ func create(u string) (backend.Server, error) {
|
||||
}
|
||||
|
||||
func init() {
|
||||
commands = make(map[string]commandFunc)
|
||||
commands["backup"] = commandBackup
|
||||
commands["restore"] = commandRestore
|
||||
commands["list"] = commandList
|
||||
|
||||
Reference in New Issue
Block a user