Rename khepri -> restic

This commit is contained in:
Alexander Neumann committed 2014-12-05 21:45:49 +01:00
1 parent 9dc0bf6378
commit e2fea0d088
41 files changed
+181 -181

No files matched your search

File renamed without changes.
+3 -3
View File
@@ -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
@@ -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",
@@ -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
@@ -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]")
}
+12 -12
View File
@@ -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]")
}
@@ -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]")
}
@@ -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
}
@@ -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" {
@@ -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 {
+3 -3
View File
@@ -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
}
File renamed without changes.
BIN
View File
Binary file not shown.
+11 -11
View File
@@ -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()
}
File renamed without changes.