diff --git a/Makefile b/Makefile index 0e35157b8..cffa22908 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ test: for dir in cmd/* ; do \ (cd "$$dir"; go build $(FLAGS)) \ done - test/run.sh cmd/khepri/khepri cmd/dirdiff/dirdiff + test/run.sh cmd/restic/restic cmd/dirdiff/dirdiff clean: go clean diff --git a/archiver.go b/archiver.go index e85f8c321..10f388e8a 100644 --- a/archiver.go +++ b/archiver.go @@ -1,4 +1,4 @@ -package khepri +package restic import ( "errors" @@ -9,9 +9,9 @@ import ( "sync" "time" - "github.com/fd0/khepri/backend" - "github.com/fd0/khepri/chunker" "github.com/juju/arrar" + "github.com/restic/restic/backend" + "github.com/restic/restic/chunker" ) const ( diff --git a/archiver_test.go b/archiver_test.go index b02310fc3..a7ca6c53e 100644 --- a/archiver_test.go +++ b/archiver_test.go @@ -1,4 +1,4 @@ -package khepri_test +package restic_test import ( "bytes" @@ -6,8 +6,8 @@ import ( "math/rand" "testing" - "github.com/fd0/khepri" - "github.com/fd0/khepri/chunker" + "github.com/restic/restic" + "github.com/restic/restic/chunker" ) func get_random(seed, count int) []byte { @@ -48,7 +48,7 @@ func BenchmarkChunkEncrypt(b *testing.B) { ok(b, err) - buf := make([]byte, khepri.CiphertextExtension+chunker.MaxSize) + buf := make([]byte, restic.CiphertextExtension+chunker.MaxSize) _, err = key.Encrypt(buf, chunk_data.Data) ok(b, err) } diff --git a/backend/doc.go b/backend/doc.go index e97cb0e7f..99661c0bc 100644 --- a/backend/doc.go +++ b/backend/doc.go @@ -1,2 +1,2 @@ -// Package backend provides local and remote storage for khepri backups. +// Package backend provides local and remote storage for restic backups. package backend diff --git a/backend/generic_test.go b/backend/generic_test.go index 818ac67a2..6deb9a07f 100644 --- a/backend/generic_test.go +++ b/backend/generic_test.go @@ -7,7 +7,7 @@ import ( "runtime" "testing" - "github.com/fd0/khepri/backend" + "github.com/restic/restic/backend" ) // assert fails the test if the condition is false. diff --git a/backend/local_test.go b/backend/local_test.go index 0c309c063..b23dbee5c 100644 --- a/backend/local_test.go +++ b/backend/local_test.go @@ -8,7 +8,7 @@ import ( "sort" "testing" - "github.com/fd0/khepri/backend" + "github.com/restic/restic/backend" ) var testCleanup = flag.Bool("test.cleanup", true, "clean up after running tests (remove local backend directory with all content)") @@ -24,7 +24,7 @@ var TestStrings = []struct { } func setupBackend(t *testing.T) *backend.Local { - tempdir, err := ioutil.TempDir("", "khepri-test-") + tempdir, err := ioutil.TempDir("", "restic-test-") ok(t, err) b, err := backend.CreateLocal(tempdir) @@ -122,9 +122,9 @@ func testBackend(b backend.Server, t *testing.T) { func TestBackend(t *testing.T) { // test for non-existing backend - b, err := backend.OpenLocal("/invalid-khepri-test") - assert(t, err != nil, "opening invalid repository at /invalid-khepri-test should have failed, but err is nil") - assert(t, b == nil, fmt.Sprintf("opening invalid repository at /invalid-khepri-test should have failed, but b is not nil: %v", b)) + b, err := backend.OpenLocal("/invalid-restic-test") + assert(t, err != nil, "opening invalid repository at /invalid-restic-test should have failed, but err is nil") + assert(t, b == nil, fmt.Sprintf("opening invalid repository at /invalid-restic-test should have failed, but b is not nil: %v", b)) b = setupBackend(t) defer teardownBackend(t, b) diff --git a/bloblist.go b/bloblist.go index 07da14cfa..d04064091 100644 --- a/bloblist.go +++ b/bloblist.go @@ -1,4 +1,4 @@ -package khepri +package restic import ( "bytes" @@ -7,7 +7,7 @@ import ( "sort" "sync" - "github.com/fd0/khepri/backend" + "github.com/restic/restic/backend" ) type BlobList struct { diff --git a/bloblist_test.go b/bloblist_test.go index dea2fbbc2..fe709bfc6 100644 --- a/bloblist_test.go +++ b/bloblist_test.go @@ -1,4 +1,4 @@ -package khepri_test +package restic_test import ( "crypto/rand" @@ -10,8 +10,8 @@ import ( "testing" "time" - "github.com/fd0/khepri" - "github.com/fd0/khepri/backend" + "github.com/restic/restic" + "github.com/restic/restic/backend" ) var maxWorkers = flag.Uint("workers", 100, "number of workers to test BlobList concurrent access against") @@ -25,13 +25,13 @@ func randomID() []byte { return buf } -func newBlob() khepri.Blob { - return khepri.Blob{ID: randomID(), Size: uint64(mrand.Uint32())} +func newBlob() restic.Blob { + return restic.Blob{ID: randomID(), Size: uint64(mrand.Uint32())} } // Test basic functionality func TestBlobList(t *testing.T) { - bl := khepri.NewBlobList() + bl := restic.NewBlobList() b := newBlob() bl.Insert(b) @@ -40,17 +40,17 @@ func TestBlobList(t *testing.T) { bl.Insert(newBlob()) } - b2, err := bl.Find(khepri.Blob{ID: b.ID}) + b2, err := bl.Find(restic.Blob{ID: b.ID}) ok(t, err) assert(t, b2.Compare(b) == 0, "items are not equal: want %v, got %v", b, b2) - bl2 := khepri.NewBlobList() + bl2 := restic.NewBlobList() for i := 0; i < 1000; i++ { bl.Insert(newBlob()) } b2, err = bl2.Find(b) - assert(t, err != nil, "found ID in khepri that was never inserted: %v", b2) + assert(t, err != nil, "found ID in restic that was never inserted: %v", b2) bl2.Merge(bl) @@ -67,8 +67,8 @@ func TestBlobList(t *testing.T) { // Test JSON encode/decode func TestBlobListJSON(t *testing.T) { - bl := khepri.NewBlobList() - b := khepri.Blob{ID: randomID()} + bl := restic.NewBlobList() + b := restic.Blob{ID: randomID()} bl.Insert(b) b2, err := bl.Find(b) @@ -78,7 +78,7 @@ func TestBlobListJSON(t *testing.T) { buf, err := json.Marshal(bl) ok(t, err) - bl2 := khepri.BlobList{} + bl2 := restic.BlobList{} json.Unmarshal(buf, &bl2) b2, err = bl2.Find(b) @@ -93,7 +93,7 @@ func TestBlobListJSON(t *testing.T) { func TestBlobListRandom(t *testing.T) { var wg sync.WaitGroup - worker := func(bl *khepri.BlobList) { + worker := func(bl *restic.BlobList) { defer wg.Done() b := newBlob() @@ -117,7 +117,7 @@ func TestBlobListRandom(t *testing.T) { } } - bl2 := khepri.NewBlobList() + bl2 := restic.NewBlobList() for i := 0; i < 200; i++ { bl2.Insert(newBlob()) } @@ -125,7 +125,7 @@ func TestBlobListRandom(t *testing.T) { bl2.Merge(bl) } - bl := khepri.NewBlobList() + bl := restic.NewBlobList() for i := 0; uint(i) < *maxWorkers; i++ { wg.Add(1) diff --git a/chunker/chunker_test.go b/chunker/chunker_test.go index a7a50b96f..0940f1f4f 100644 --- a/chunker/chunker_test.go +++ b/chunker/chunker_test.go @@ -6,7 +6,7 @@ import ( "math/rand" "testing" - "github.com/fd0/khepri/chunker" + "github.com/restic/restic/chunker" ) type chunk struct { diff --git a/cmd/khepri/.gitignore b/cmd/restic/.gitignore similarity index 100% rename from cmd/khepri/.gitignore rename to cmd/restic/.gitignore diff --git a/cmd/khepri/Makefile b/cmd/restic/Makefile similarity index 78% rename from cmd/khepri/Makefile rename to cmd/restic/Makefile index 078778d7f..b9484168e 100644 --- a/cmd/khepri/Makefile +++ b/cmd/restic/Makefile @@ -9,13 +9,13 @@ TAGS = # include config file if it exists -include $(CURDIR)/config.mk -all: khepri +all: restic -khepri: $(wildcard *.go) $(wildcard ../../*.go) $(wildcard ../../*/*.go) +restic: $(wildcard *.go) $(wildcard ../../*.go) $(wildcard ../../*/*.go) go build $(TAGS) -ldflags "$(LDFLAGS)" debug: TAGS=-tags debug_cmd -debug: khepri +debug: restic clean: go clean diff --git a/cmd/khepri/cmd_backup.go b/cmd/restic/cmd_backup.go similarity index 90% rename from cmd/khepri/cmd_backup.go rename to cmd/restic/cmd_backup.go index 964e8c439..626d2a170 100644 --- a/cmd/khepri/cmd_backup.go +++ b/cmd/restic/cmd_backup.go @@ -7,8 +7,8 @@ import ( "strings" "time" - "github.com/fd0/khepri" - "github.com/fd0/khepri/backend" + "github.com/restic/restic" + "github.com/restic/restic/backend" "golang.org/x/crypto/ssh/terminal" ) @@ -45,7 +45,7 @@ func format_duration(sec uint64) string { return fmt.Sprintf("%d:%02d", min, sec) } -func print_tree2(indent int, t *khepri.Tree) { +func print_tree2(indent int, t *restic.Tree) { for _, node := range *t { if node.Tree != nil { fmt.Printf("%s%s/\n", strings.Repeat(" ", indent), node.Name) @@ -56,7 +56,7 @@ func print_tree2(indent int, t *khepri.Tree) { } } -func commandBackup(be backend.Server, key *khepri.Key, args []string) error { +func commandBackup(be backend.Server, key *restic.Key, args []string) error { if len(args) < 1 || len(args) > 2 { return errors.New("usage: backup [dir|file] [snapshot-id]") } @@ -74,7 +74,7 @@ func commandBackup(be backend.Server, key *khepri.Key, args []string) error { fmt.Printf("found parent snapshot %v\n", parentSnapshotID) } - arch, err := khepri.NewArchiver(be, key) + arch, err := restic.NewArchiver(be, key) if err != nil { fmt.Fprintf(os.Stderr, "err: %v\n", err) } @@ -87,10 +87,10 @@ func commandBackup(be backend.Server, key *khepri.Key, args []string) error { fmt.Printf("scanning %s\n", target) if terminal.IsTerminal(int(os.Stdout.Fd())) { - ch := make(chan khepri.Stats, 20) + ch := make(chan restic.Stats, 20) arch.ScannerStats = ch - go func(ch <-chan khepri.Stats) { + go func(ch <-chan restic.Stats) { for stats := range ch { fmt.Printf("\r%6d directories, %6d files, %14s", stats.Directories, stats.Files, format_bytes(stats.Bytes)) } @@ -112,16 +112,16 @@ func commandBackup(be backend.Server, key *khepri.Key, args []string) error { fmt.Printf("\r%6d directories, %6d files, %14s\n", arch.Stats.Directories, arch.Stats.Files, format_bytes(arch.Stats.Bytes)) - stats := khepri.Stats{} + stats := restic.Stats{} start := time.Now() if terminal.IsTerminal(int(os.Stdout.Fd())) { - ch := make(chan khepri.Stats, 20) + ch := make(chan restic.Stats, 20) arch.SaveStats = ch ticker := time.NewTicker(time.Second) var eta, bps uint64 - go func(ch <-chan khepri.Stats) { + go func(ch <-chan restic.Stats) { status := func(sec uint64) { fmt.Printf("\x1b[2K\r[%s] %3.2f%% %s/s %s / %s ETA %s", diff --git a/cmd/khepri/cmd_cat.go b/cmd/restic/cmd_cat.go similarity index 89% rename from cmd/khepri/cmd_cat.go rename to cmd/restic/cmd_cat.go index 7e892dddf..55cd43bc1 100644 --- a/cmd/khepri/cmd_cat.go +++ b/cmd/restic/cmd_cat.go @@ -6,15 +6,15 @@ import ( "fmt" "os" - "github.com/fd0/khepri" - "github.com/fd0/khepri/backend" + "github.com/restic/restic" + "github.com/restic/restic/backend" ) func init() { commands["cat"] = commandCat } -func commandCat(be backend.Server, key *khepri.Key, args []string) error { +func commandCat(be backend.Server, key *restic.Key, args []string) error { if len(args) != 2 { return errors.New("usage: cat [blob|tree|snapshot|key|lock] ID") } @@ -36,7 +36,7 @@ func commandCat(be backend.Server, key *khepri.Key, args []string) error { } } - ch, err := khepri.NewContentHandler(be, key) + ch, err := restic.NewContentHandler(be, key) if err != nil { return err } @@ -71,7 +71,7 @@ func commandCat(be backend.Server, key *khepri.Key, args []string) error { return err case "tree": - var tree khepri.Tree + var tree restic.Tree // try id err := ch.LoadJSON(backend.Tree, id, &tree) if err != nil { @@ -103,7 +103,7 @@ func commandCat(be backend.Server, key *khepri.Key, args []string) error { return nil case "map": - var bl khepri.BlobList + var bl restic.BlobList err := ch.LoadJSONRaw(backend.Map, id, &bl) if err != nil { return err @@ -118,7 +118,7 @@ func commandCat(be backend.Server, key *khepri.Key, args []string) error { return nil case "snapshot": - var sn khepri.Snapshot + var sn restic.Snapshot err = ch.LoadJSONRaw(backend.Snapshot, id, &sn) if err != nil { @@ -139,7 +139,7 @@ func commandCat(be backend.Server, key *khepri.Key, args []string) error { return err } - var key khepri.Key + var key restic.Key err = json.Unmarshal(data, &key) if err != nil { return err diff --git a/cmd/khepri/cmd_fsck.go b/cmd/restic/cmd_fsck.go similarity index 82% rename from cmd/khepri/cmd_fsck.go rename to cmd/restic/cmd_fsck.go index b8a2ce716..ac21987d6 100644 --- a/cmd/khepri/cmd_fsck.go +++ b/cmd/restic/cmd_fsck.go @@ -4,15 +4,15 @@ import ( "errors" "fmt" - "github.com/fd0/khepri" - "github.com/fd0/khepri/backend" + "github.com/restic/restic" + "github.com/restic/restic/backend" ) func init() { commands["fsck"] = commandFsck } -func fsckFile(ch *khepri.ContentHandler, IDs []backend.ID) error { +func fsckFile(ch *restic.ContentHandler, IDs []backend.ID) error { for _, id := range IDs { debug("checking data blob %v\n", id) @@ -26,10 +26,10 @@ func fsckFile(ch *khepri.ContentHandler, IDs []backend.ID) error { return nil } -func fsckTree(ch *khepri.ContentHandler, id backend.ID) error { +func fsckTree(ch *restic.ContentHandler, id backend.ID) error { debug("checking tree %v\n", id) - tree, err := khepri.LoadTree(ch, id) + tree, err := restic.LoadTree(ch, id) if err != nil { return err } @@ -68,10 +68,10 @@ func fsckTree(ch *khepri.ContentHandler, id backend.ID) error { return nil } -func fsck_snapshot(be backend.Server, key *khepri.Key, id backend.ID) error { +func fsck_snapshot(be backend.Server, key *restic.Key, id backend.ID) error { debug("checking snapshot %v\n", id) - ch, err := khepri.NewContentHandler(be, key) + ch, err := restic.NewContentHandler(be, key) if err != nil { return err } @@ -92,7 +92,7 @@ func fsck_snapshot(be backend.Server, key *khepri.Key, id backend.ID) error { return fsckTree(ch, sn.Content) } -func commandFsck(be backend.Server, key *khepri.Key, args []string) error { +func commandFsck(be backend.Server, key *restic.Key, args []string) error { if len(args) == 0 { return errors.New("usage: fsck [all|snapshot-id]") } diff --git a/cmd/khepri/cmd_key.go b/cmd/restic/cmd_key.go similarity index 75% rename from cmd/khepri/cmd_key.go rename to cmd/restic/cmd_key.go index 4aab50c4f..bec18e3d7 100644 --- a/cmd/khepri/cmd_key.go +++ b/cmd/restic/cmd_key.go @@ -6,15 +6,15 @@ import ( "fmt" "os" - "github.com/fd0/khepri" - "github.com/fd0/khepri/backend" + "github.com/restic/restic" + "github.com/restic/restic/backend" ) func init() { commands["key"] = commandKey } -func list_keys(be backend.Server, key *khepri.Key) error { +func list_keys(be backend.Server, key *restic.Key) error { tab := NewTable() tab.Header = fmt.Sprintf(" %-10s %-10s %-10s %s", "ID", "User", "Host", "Created") tab.RowFormat = "%s%-10s %-10s %-10s %s" @@ -25,7 +25,7 @@ func list_keys(be backend.Server, key *khepri.Key) error { } backend.Each(be, backend.Key, func(id backend.ID, data []byte, err error) { - k := khepri.Key{} + k := restic.Key{} err = json.Unmarshal(data, &k) if err != nil { return @@ -46,9 +46,9 @@ func list_keys(be backend.Server, key *khepri.Key) error { return nil } -func add_key(be backend.Server, key *khepri.Key) error { - pw := readPassword("KHEPRI_NEWPASSWORD", "enter password for new key: ") - pw2 := readPassword("KHEPRI_NEWPASSWORD", "enter password again: ") +func add_key(be backend.Server, key *restic.Key) error { + pw := readPassword("RESTIC_NEWPASSWORD", "enter password for new key: ") + pw2 := readPassword("RESTIC_NEWPASSWORD", "enter password again: ") if pw != pw2 { return errors.New("passwords do not match") @@ -64,7 +64,7 @@ func add_key(be backend.Server, key *khepri.Key) error { return nil } -func delete_key(be backend.Server, key *khepri.Key, id backend.ID) error { +func delete_key(be backend.Server, key *restic.Key, id backend.ID) error { if id.Equal(key.ID()) { return errors.New("refusing to remove key currently used to access repository") } @@ -78,9 +78,9 @@ func delete_key(be backend.Server, key *khepri.Key, id backend.ID) error { return nil } -func change_password(be backend.Server, key *khepri.Key) error { - pw := readPassword("KHEPRI_NEWPASSWORD", "enter password for new key: ") - pw2 := readPassword("KHEPRI_NEWPASSWORD", "enter password again: ") +func change_password(be backend.Server, key *restic.Key) error { + pw := readPassword("RESTIC_NEWPASSWORD", "enter password for new key: ") + pw2 := readPassword("RESTIC_NEWPASSWORD", "enter password again: ") if pw != pw2 { return errors.New("passwords do not match") @@ -103,7 +103,7 @@ func change_password(be backend.Server, key *khepri.Key) error { return nil } -func commandKey(be backend.Server, key *khepri.Key, args []string) error { +func commandKey(be backend.Server, key *restic.Key, args []string) error { if len(args) < 1 || (args[0] == "rm" && len(args) != 2) { return errors.New("usage: key [list|add|rm|change] [ID]") } diff --git a/cmd/khepri/cmd_list.go b/cmd/restic/cmd_list.go similarity index 86% rename from cmd/khepri/cmd_list.go rename to cmd/restic/cmd_list.go index 6965cd022..3f0bb0e67 100644 --- a/cmd/khepri/cmd_list.go +++ b/cmd/restic/cmd_list.go @@ -4,15 +4,15 @@ import ( "errors" "fmt" - "github.com/fd0/khepri" - "github.com/fd0/khepri/backend" + "github.com/restic/restic" + "github.com/restic/restic/backend" ) func init() { commands["list"] = commandList } -func commandList(be backend.Server, key *khepri.Key, args []string) error { +func commandList(be backend.Server, key *restic.Key, args []string) error { if len(args) != 1 { return errors.New("usage: list [data|trees|snapshots|keys|locks]") } diff --git a/cmd/khepri/cmd_ls.go b/cmd/restic/cmd_ls.go similarity index 81% rename from cmd/khepri/cmd_ls.go rename to cmd/restic/cmd_ls.go index 89b5adfa5..829bef756 100644 --- a/cmd/khepri/cmd_ls.go +++ b/cmd/restic/cmd_ls.go @@ -6,15 +6,15 @@ import ( "os" "path/filepath" - "github.com/fd0/khepri" - "github.com/fd0/khepri/backend" + "github.com/restic/restic" + "github.com/restic/restic/backend" ) func init() { commands["ls"] = commandLs } -func print_node(prefix string, n *khepri.Node) string { +func print_node(prefix string, n *restic.Node) string { switch n.Type { case "file": return fmt.Sprintf("%s %5d %5d %6d %s %s", @@ -30,8 +30,8 @@ func print_node(prefix string, n *khepri.Node) string { } } -func print_tree(prefix string, ch *khepri.ContentHandler, id backend.ID) error { - tree := &khepri.Tree{} +func print_tree(prefix string, ch *restic.ContentHandler, id backend.ID) error { + tree := &restic.Tree{} err := ch.LoadJSON(backend.Tree, id, tree) if err != nil { @@ -52,7 +52,7 @@ func print_tree(prefix string, ch *khepri.ContentHandler, id backend.ID) error { return nil } -func commandLs(be backend.Server, key *khepri.Key, args []string) error { +func commandLs(be backend.Server, key *restic.Key, args []string) error { if len(args) < 1 || len(args) > 2 { return errors.New("usage: ls SNAPSHOT_ID [dir]") } @@ -62,7 +62,7 @@ func commandLs(be backend.Server, key *khepri.Key, args []string) error { return err } - ch, err := khepri.NewContentHandler(be, key) + ch, err := restic.NewContentHandler(be, key) if err != nil { return err } diff --git a/cmd/khepri/cmd_restore.go b/cmd/restic/cmd_restore.go similarity index 79% rename from cmd/khepri/cmd_restore.go rename to cmd/restic/cmd_restore.go index 921fdcf70..bc0afe99e 100644 --- a/cmd/khepri/cmd_restore.go +++ b/cmd/restic/cmd_restore.go @@ -5,15 +5,15 @@ import ( "fmt" "os" - "github.com/fd0/khepri" - "github.com/fd0/khepri/backend" + "github.com/restic/restic" + "github.com/restic/restic/backend" ) func init() { commands["restore"] = commandRestore } -func commandRestore(be backend.Server, key *khepri.Key, args []string) error { +func commandRestore(be backend.Server, key *restic.Key, args []string) error { if len(args) != 2 { return errors.New("usage: restore ID dir") } @@ -26,13 +26,13 @@ func commandRestore(be backend.Server, key *khepri.Key, args []string) error { target := args[1] // create restorer - res, err := khepri.NewRestorer(be, key, id) + res, err := restic.NewRestorer(be, key, id) if err != nil { fmt.Fprintf(os.Stderr, "creating restorer failed: %v\n", err) os.Exit(2) } - res.Error = func(dir string, node *khepri.Node, err error) error { + res.Error = func(dir string, node *restic.Node, err error) error { fmt.Fprintf(os.Stderr, "error for %s: %+v\n", dir, err) // if node.Type == "dir" { diff --git a/cmd/khepri/cmd_snapshots.go b/cmd/restic/cmd_snapshots.go similarity index 91% rename from cmd/khepri/cmd_snapshots.go rename to cmd/restic/cmd_snapshots.go index 98db23021..b769ef9b5 100644 --- a/cmd/khepri/cmd_snapshots.go +++ b/cmd/restic/cmd_snapshots.go @@ -9,8 +9,8 @@ import ( "strings" "time" - "github.com/fd0/khepri" - "github.com/fd0/khepri/backend" + "github.com/restic/restic" + "github.com/restic/restic/backend" ) const ( @@ -76,12 +76,12 @@ func init() { commands["snapshots"] = commandSnapshots } -func commandSnapshots(be backend.Server, key *khepri.Key, args []string) error { +func commandSnapshots(be backend.Server, key *restic.Key, args []string) error { if len(args) != 0 { return errors.New("usage: snapshots") } - ch, err := khepri.NewContentHandler(be, key) + ch, err := restic.NewContentHandler(be, key) if err != nil { return err } @@ -90,7 +90,7 @@ func commandSnapshots(be backend.Server, key *khepri.Key, args []string) error { tab.Header = fmt.Sprintf("%-8s %-19s %-10s %s", "ID", "Date", "Source", "Directory") tab.RowFormat = "%-8s %-19s %-10s %s" - list := []*khepri.Snapshot{} + list := []*restic.Snapshot{} backend.EachID(be, backend.Snapshot, func(id backend.ID) { sn, err := ch.LoadSnapshot(id) if err != nil { diff --git a/cmd/khepri/debug.go b/cmd/restic/debug.go similarity index 82% rename from cmd/khepri/debug.go rename to cmd/restic/debug.go index dc978a51a..bb3c18b60 100644 --- a/cmd/khepri/debug.go +++ b/cmd/restic/debug.go @@ -15,7 +15,7 @@ var debugLogger = initDebugLogger() func initDebugLogger() *log.Logger { // create new log file - filename := fmt.Sprintf("khepri-debug-%d-%s", + filename := fmt.Sprintf("restic-debug-%d-%s", os.Getpid(), time.Now().Format("20060201-150405")) path := filepath.Join(os.TempDir(), filename) f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE, 0600) @@ -26,8 +26,8 @@ func initDebugLogger() *log.Logger { // open logger l := log.New(io.MultiWriter(os.Stderr, f), "DEBUG: ", log.LstdFlags) - fmt.Fprintf(os.Stderr, "debug log for khepri command activated, writing log file %s\n", path) - l.Printf("khepri %s", version) + fmt.Fprintf(os.Stderr, "debug log for restic command activated, writing log file %s\n", path) + l.Printf("restic %s", version) return l } diff --git a/cmd/khepri/debug_release.go b/cmd/restic/debug_release.go similarity index 100% rename from cmd/khepri/debug_release.go rename to cmd/restic/debug_release.go diff --git a/cmd/restic/khepri b/cmd/restic/khepri new file mode 100755 index 000000000..e77b32cc9 Binary files /dev/null and b/cmd/restic/khepri differ diff --git a/cmd/khepri/main.go b/cmd/restic/main.go similarity index 86% rename from cmd/khepri/main.go rename to cmd/restic/main.go index a774f5205..422b3a460 100644 --- a/cmd/khepri/main.go +++ b/cmd/restic/main.go @@ -11,9 +11,9 @@ import ( "golang.org/x/crypto/ssh/terminal" - "github.com/fd0/khepri" - "github.com/fd0/khepri/backend" "github.com/jessevdk/go-flags" + "github.com/restic/restic" + "github.com/restic/restic/backend" ) var version = "compiled manually" @@ -30,7 +30,7 @@ func errx(code int, format string, data ...interface{}) { os.Exit(code) } -type commandFunc func(backend.Server, *khepri.Key, []string) error +type commandFunc func(backend.Server, *restic.Key, []string) error var commands = make(map[string]commandFunc) @@ -55,8 +55,8 @@ func readPassword(env string, prompt string) string { } func commandInit(repo string) error { - pw := readPassword("KHEPRI_PASSWORD", "enter password for new backend: ") - pw2 := readPassword("KHEPRI_PASSWORD", "enter password again: ") + pw := readPassword("RESTIC_PASSWORD", "enter password for new backend: ") + pw2 := readPassword("RESTIC_PASSWORD", "enter password again: ") if pw != pw2 { errx(1, "passwords do not match") @@ -68,13 +68,13 @@ func commandInit(repo string) error { os.Exit(1) } - _, err = khepri.CreateKey(be, pw) + _, err = restic.CreateKey(be, pw) if err != nil { fmt.Fprintf(os.Stderr, "creating key in backend at %s failed: %v\n", repo, err) os.Exit(1) } - fmt.Printf("created khepri backend at %s\n", be.Location()) + fmt.Printf("created restic backend at %s\n", be.Location()) return nil } @@ -135,7 +135,7 @@ func main() { log.SetOutput(os.Stdout) - opts.Repo = os.Getenv("KHEPRI_REPOSITORY") + opts.Repo = os.Getenv("RESTIC_REPOSITORY") args, err := flags.Parse(&opts) if e, ok := err.(*flags.Error); ok && e.Type == flags.ErrHelp { @@ -143,7 +143,7 @@ func main() { } if opts.Repo == "" { - fmt.Fprintf(os.Stderr, "no repository specified, use -r or KHEPRI_REPOSITORY variable\n") + fmt.Fprintf(os.Stderr, "no repository specified, use -r or RESTIC_REPOSITORY variable\n") os.Exit(1) } @@ -183,7 +183,7 @@ func main() { errx(1, "unable to open repo: %v", err) } - key, err := khepri.SearchKey(repo, readPassword("KHEPRI_PASSWORD", "Enter Password for Repository: ")) + key, err := restic.SearchKey(repo, readPassword("RESTIC_PASSWORD", "Enter Password for Repository: ")) if err != nil { errx(2, "unable to open repo: %v", err) } @@ -193,5 +193,5 @@ func main() { errx(1, "error executing command %q: %v", cmd, err) } - khepri.PoolAlloc() + restic.PoolAlloc() } diff --git a/cmd/khepri/version.sh b/cmd/restic/version.sh similarity index 100% rename from cmd/khepri/version.sh rename to cmd/restic/version.sh diff --git a/contenthandler.go b/contenthandler.go index 9661a44af..bf43255d1 100644 --- a/contenthandler.go +++ b/contenthandler.go @@ -1,11 +1,11 @@ -package khepri +package restic import ( "encoding/json" "errors" "fmt" - "github.com/fd0/khepri/backend" + "github.com/restic/restic/backend" ) var ErrWrongData = errors.New("wrong data decrypt, checksum does not match") diff --git a/debug.go b/debug.go index 80952b3e7..2e51cc2f9 100644 --- a/debug.go +++ b/debug.go @@ -1,6 +1,6 @@ // +build debug -package khepri +package restic import ( "fmt" @@ -15,7 +15,7 @@ var debugLogger = initDebugLogger() func initDebugLogger() *log.Logger { // create new log file - filename := fmt.Sprintf("khepri-lib-debug-%d-%s", + filename := fmt.Sprintf("restic-lib-debug-%d-%s", os.Getpid(), time.Now().Format("20060201-150405")) path := filepath.Join(os.TempDir(), filename) f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE, 0600) @@ -26,7 +26,7 @@ func initDebugLogger() *log.Logger { // open logger l := log.New(io.MultiWriter(os.Stderr, f), "DEBUG: ", log.LstdFlags) - fmt.Fprintf(os.Stderr, "debug log for khepri library activated, writing log file %s\n", path) + fmt.Fprintf(os.Stderr, "debug log for restic library activated, writing log file %s\n", path) return l } diff --git a/debug_release.go b/debug_release.go index 21f2b24a5..d49429aa9 100644 --- a/debug_release.go +++ b/debug_release.go @@ -1,5 +1,5 @@ // +build !debug -package khepri +package restic func debug(fmt string, args ...interface{}) {} diff --git a/generic_test.go b/generic_test.go index 491afbc68..3bb942fa0 100644 --- a/generic_test.go +++ b/generic_test.go @@ -1,4 +1,4 @@ -package khepri_test +package restic_test import ( "fmt" diff --git a/key.go b/key.go index 1acdca08f..4889047de 100644 --- a/key.go +++ b/key.go @@ -1,4 +1,4 @@ -package khepri +package restic import ( "crypto/aes" @@ -14,8 +14,8 @@ import ( "os/user" "time" - "github.com/fd0/khepri/backend" - "github.com/fd0/khepri/chunker" + "github.com/restic/restic/backend" + "github.com/restic/restic/chunker" "golang.org/x/crypto/scrypt" ) diff --git a/key_int_test.go b/key_int_test.go index ffdd13bcd..1298ccc32 100644 --- a/key_int_test.go +++ b/key_int_test.go @@ -1,4 +1,4 @@ -package khepri +package restic import ( "bytes" diff --git a/key_test.go b/key_test.go index 366002617..49e47ed5c 100644 --- a/key_test.go +++ b/key_test.go @@ -1,4 +1,4 @@ -package khepri_test +package restic_test import ( "flag" @@ -7,16 +7,16 @@ import ( "os" "testing" - "github.com/fd0/khepri" - "github.com/fd0/khepri/backend" - "github.com/fd0/khepri/chunker" + "github.com/restic/restic" + "github.com/restic/restic/backend" + "github.com/restic/restic/chunker" ) var testPassword = "foobar" var testCleanup = flag.Bool("test.cleanup", true, "clean up after running tests (remove local backend directory with all content)") func setupBackend(t testing.TB) *backend.Local { - tempdir, err := ioutil.TempDir("", "khepri-test-") + tempdir, err := ioutil.TempDir("", "restic-test-") ok(t, err) b, err := backend.CreateLocal(tempdir) @@ -34,8 +34,8 @@ func teardownBackend(t testing.TB, b *backend.Local) { ok(t, os.RemoveAll(b.Location())) } -func setupKey(t testing.TB, be backend.Server, password string) *khepri.Key { - k, err := khepri.CreateKey(be, password) +func setupKey(t testing.TB, be backend.Server, password string) *restic.Key { + k, err := restic.CreateKey(be, password) ok(t, err) return k @@ -60,14 +60,14 @@ func TestEncryptDecrypt(t *testing.T) { _, err = io.ReadFull(f, data) ok(t, err) - ciphertext := khepri.GetChunkBuf("TestEncryptDecrypt") + ciphertext := restic.GetChunkBuf("TestEncryptDecrypt") n, err := k.Encrypt(ciphertext, data) ok(t, err) plaintext, err := k.Decrypt(ciphertext[:n]) ok(t, err) - khepri.FreeChunkBuf("TestEncryptDecrypt", ciphertext) + restic.FreeChunkBuf("TestEncryptDecrypt", ciphertext) equals(t, plaintext, data) } @@ -86,7 +86,7 @@ func TestLargeEncrypt(t *testing.T) { _, err = io.ReadFull(f, data) ok(t, err) - ciphertext := make([]byte, size+khepri.CiphertextExtension) + ciphertext := make([]byte, size+restic.CiphertextExtension) n, err := k.Encrypt(ciphertext, data) ok(t, err) @@ -108,12 +108,12 @@ func BenchmarkEncrypt(b *testing.B) { b.ResetTimer() b.SetBytes(int64(size)) - buf := khepri.GetChunkBuf("BenchmarkEncrypt") + buf := restic.GetChunkBuf("BenchmarkEncrypt") for i := 0; i < b.N; i++ { _, err := k.Encrypt(buf, data) ok(b, err) } - khepri.FreeChunkBuf("BenchmarkEncrypt", buf) + restic.FreeChunkBuf("BenchmarkEncrypt", buf) } func BenchmarkDecrypt(b *testing.B) { @@ -124,7 +124,7 @@ func BenchmarkDecrypt(b *testing.B) { defer teardownBackend(b, be) k := setupKey(b, be, testPassword) - ciphertext := khepri.GetChunkBuf("BenchmarkDecrypt") + ciphertext := restic.GetChunkBuf("BenchmarkDecrypt") n, err := k.Encrypt(ciphertext, data) ok(b, err) @@ -135,5 +135,5 @@ func BenchmarkDecrypt(b *testing.B) { _, err := k.Decrypt(ciphertext[:n]) ok(b, err) } - khepri.FreeChunkBuf("BenchmarkDecrypt", ciphertext) + restic.FreeChunkBuf("BenchmarkDecrypt", ciphertext) } diff --git a/pools.go b/pools.go index c13857eb7..4077a15d8 100644 --- a/pools.go +++ b/pools.go @@ -1,4 +1,4 @@ -package khepri +package restic import "sync" diff --git a/restorer.go b/restorer.go index c1717db3f..329dd09c1 100644 --- a/restorer.go +++ b/restorer.go @@ -1,4 +1,4 @@ -package khepri +package restic import ( "errors" @@ -6,8 +6,8 @@ import ( "os" "path/filepath" - "github.com/fd0/khepri/backend" "github.com/juju/arrar" + "github.com/restic/restic/backend" ) type Restorer struct { diff --git a/snapshot.go b/snapshot.go index 1e592a178..bdc2bca61 100644 --- a/snapshot.go +++ b/snapshot.go @@ -1,4 +1,4 @@ -package khepri +package restic import ( "fmt" @@ -7,7 +7,7 @@ import ( "path/filepath" "time" - "github.com/fd0/khepri/backend" + "github.com/restic/restic/backend" ) type Snapshot struct { diff --git a/snapshot_test.go b/snapshot_test.go index d06ec077c..62b624361 100644 --- a/snapshot_test.go +++ b/snapshot_test.go @@ -1,16 +1,16 @@ -package khepri_test +package restic_test import ( "testing" "time" - "github.com/fd0/khepri" - "github.com/fd0/khepri/backend" + "github.com/restic/restic" + "github.com/restic/restic/backend" ) func testSnapshot(t *testing.T, be backend.Server) { var err error - sn := khepri.NewSnapshot("/home/foobar") + sn := restic.NewSnapshot("/home/foobar") sn.Content, err = backend.ParseID("c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2") ok(t, err) sn.Time, err = time.Parse(time.RFC3339Nano, "2014-08-03T17:49:05.378595539+02:00") diff --git a/test/run.sh b/test/run.sh index 12e03eb57..697a3895f 100755 --- a/test/run.sh +++ b/test/run.sh @@ -2,17 +2,17 @@ set -e -export khepri="${1:-khepri}"; shift +export restic="${1:-restic}"; shift export dirdiff="${1:-dirdiff}"; shift export dir=$(dirname "$0") export fake_data_file="${dir}/fake-data.tar.gz" prepare() { - export BASE="$(mktemp --tmpdir --directory khepri-testsuite-XXXXXX)" - export KHEPRI_REPOSITORY="${BASE}/khepri-backup" + export BASE="$(mktemp --tmpdir --directory restic-testsuite-XXXXXX)" + export RESTIC_REPOSITORY="${BASE}/restic-backup" export DATADIR="${BASE}/fake-data" - export KHEPRI_PASSWORD="foobar" - debug "repository is at ${KHEPRI_REPOSITORY}" + export RESTIC_PASSWORD="foobar" + debug "repository is at ${RESTIC_REPOSITORY}" mkdir -p "$DATADIR" (cd "$DATADIR"; tar xz) < "$fake_data_file" @@ -28,11 +28,11 @@ cleanup() { rm -rf "${BASE}" debug "removed dir ${BASE}" unset BASE - unset KHEPRI_REPOSITORY + unset RESTIC_REPOSITORY } -khepri() { - "${khepri}" "$@" +restic() { + "${restic}" "$@" } dirdiff() { @@ -70,10 +70,10 @@ run() { fi } -export -f khepri dirdiff prepare cleanup msg debug pass err fail run +export -f restic dirdiff prepare cleanup msg debug pass err fail run -if [ ! -x "$khepri" ]; then - fail khepri binary not found! +if [ ! -x "$restic" ]; then + fail restic binary not found! fi if [ "$#" -gt 0 ]; then diff --git a/test/test-backup.sh b/test/test-backup.sh index b208eaab2..273b7401b 100755 --- a/test/test-backup.sh +++ b/test/test-backup.sh @@ -1,15 +1,15 @@ set -e prepare -run khepri init -run khepri backup "${BASE}/fake-data" -run khepri restore "$(basename "$KHEPRI_REPOSITORY"/snapshots/*)" "${BASE}/fake-data-restore" +run restic init +run restic backup "${BASE}/fake-data" +run restic restore "$(basename "$RESTIC_REPOSITORY"/snapshots/*)" "${BASE}/fake-data-restore" dirdiff "${BASE}/fake-data" "${BASE}/fake-data-restore/fake-data" -SNAPSHOT=$(run khepri list snapshots) -run khepri backup "${BASE}/fake-data" $SNAPSHOT -run khepri restore "$(basename "$KHEPRI_REPOSITORY"/snapshots/*)" "${BASE}/fake-data-restore-incremental" +SNAPSHOT=$(run restic list snapshots) +run restic backup "${BASE}/fake-data" $SNAPSHOT +run restic restore "$(basename "$RESTIC_REPOSITORY"/snapshots/*)" "${BASE}/fake-data-restore-incremental" dirdiff "${BASE}/fake-data" "${BASE}/fake-data-restore-incremental/fake-data" -run khepri fsck all +run restic fsck all cleanup diff --git a/test/test-key-add-remove.sh b/test/test-key-add-remove.sh index 1fa5fa927..9bd626827 100755 --- a/test/test-key-add-remove.sh +++ b/test/test-key-add-remove.sh @@ -2,7 +2,7 @@ set -e dump_repo() { if [ "$FAILED" == "1" ]; then - tar cvz "$KHEPRI_REPOSITORY" | base64 >&2 + tar cvz "$RESTIC_REPOSITORY" | base64 >&2 fi } @@ -11,31 +11,31 @@ FAILED=1 trap dump_repo 0 prepare -unset KHEPRI_PASSWORD -KHEPRI_PASSWORD=foo run khepri init -KHEPRI_PASSWORD=foo run khepri key list +unset RESTIC_PASSWORD +RESTIC_PASSWORD=foo run restic init +RESTIC_PASSWORD=foo run restic key list -KHEPRI_PASSWORD=foo KHEPRI_NEWPASSWORD=foobar run khepri key change -KHEPRI_PASSWORD=foobar run khepri key list -KHEPRI_PASSWORD=foobar KHEPRI_NEWPASSWORD=foo run khepri key change +RESTIC_PASSWORD=foo RESTIC_NEWPASSWORD=foobar run restic key change +RESTIC_PASSWORD=foobar run restic key list +RESTIC_PASSWORD=foobar RESTIC_NEWPASSWORD=foo run restic key change OLD_PWD=foo for i in {1..3}; do NEW_PWD=bar$i - KHEPRI_PASSWORD=$OLD_PWD KHEPRI_NEWPASSWORD=$NEW_PWD run khepri key add - KHEPRI_PASSWORD=$OLD_PWD run khepri key list - KHEPRI_PASSWORD=$NEW_PWD run khepri key list + RESTIC_PASSWORD=$OLD_PWD RESTIC_NEWPASSWORD=$NEW_PWD run restic key add + RESTIC_PASSWORD=$OLD_PWD run restic key list + RESTIC_PASSWORD=$NEW_PWD run restic key list - export KHEPRI_PASSWORD=$OLD_PWD - ID=$(khepri key list | grep '^\*'|cut -d ' ' -f 1| sed 's/^.//') - unset KHEPRI_PASSWORD - KHEPRI_PASSWORD=$NEW_PWD run khepri key rm $ID - KHEPRI_PASSWORD=$NEW_PWD run khepri key list + export RESTIC_PASSWORD=$OLD_PWD + ID=$(restic key list | grep '^\*'|cut -d ' ' -f 1| sed 's/^.//') + unset RESTIC_PASSWORD + RESTIC_PASSWORD=$NEW_PWD run restic key rm $ID + RESTIC_PASSWORD=$NEW_PWD run restic key list OLD_PWD=bar$i done -KHEPRI_PASSWORD=$OLD_PWD run khepri fsck all +RESTIC_PASSWORD=$OLD_PWD run restic fsck all cleanup diff --git a/tree.go b/tree.go index b5b92e885..1fe48cf97 100644 --- a/tree.go +++ b/tree.go @@ -1,4 +1,4 @@ -package khepri +package restic import ( "errors" @@ -11,8 +11,8 @@ import ( "syscall" "time" - "github.com/fd0/khepri/backend" "github.com/juju/arrar" + "github.com/restic/restic/backend" ) type Tree []*Node diff --git a/tree_test.go b/tree_test.go index 85076367e..bd1ba191c 100644 --- a/tree_test.go +++ b/tree_test.go @@ -1,4 +1,4 @@ -package khepri_test +package restic_test import ( "io/ioutil" @@ -18,7 +18,7 @@ var testFiles = []struct { // prepareDir creates a temporary directory and returns it. func prepareDir(t *testing.T) string { - tempdir, err := ioutil.TempDir("", "khepri-test-") + tempdir, err := ioutil.TempDir("", "restic-test-") ok(t, err) for _, test := range testFiles { diff --git a/zerrors_linux.go b/zerrors_linux.go index 8ba94670a..c90a86293 100644 --- a/zerrors_linux.go +++ b/zerrors_linux.go @@ -1,4 +1,4 @@ -package khepri +package restic // Add constant O_PATH missing from Go1.3, will be added to Go1.4 according to // https://code.google.com/p/go/issues/detail?id=7830