mirror of
https://github.com/octoleo/restic.git
synced 2024-12-23 11:28:54 +00:00
Dump individual indexes
This commit is contained in:
parent
96f2165067
commit
de2c20be84
@ -17,6 +17,8 @@ import (
|
||||
|
||||
type CmdDump struct {
|
||||
global *GlobalOptions
|
||||
|
||||
repo *repository.Repository
|
||||
}
|
||||
|
||||
func init() {
|
||||
@ -94,6 +96,27 @@ func printTrees(repo *repository.Repository, wr io.Writer) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cmd CmdDump) DumpIndexes() error {
|
||||
done := make(chan struct{})
|
||||
defer close(done)
|
||||
|
||||
for id := range cmd.repo.List(backend.Index, done) {
|
||||
fmt.Printf("index_id: %v\n", id)
|
||||
|
||||
idx, err := repository.LoadIndex(cmd.repo, id.String())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = idx.Dump(os.Stdout)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cmd CmdDump) Execute(args []string) error {
|
||||
if len(args) != 1 {
|
||||
return fmt.Errorf("type not specified, Usage: %s", cmd.Usage())
|
||||
@ -103,6 +126,7 @@ func (cmd CmdDump) Execute(args []string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cmd.repo = repo
|
||||
|
||||
lock, err := lockRepo(repo)
|
||||
defer unlockRepo(lock)
|
||||
@ -120,6 +144,8 @@ func (cmd CmdDump) Execute(args []string) error {
|
||||
switch tpe {
|
||||
case "index":
|
||||
return repo.Index().Dump(os.Stdout)
|
||||
case "indexes":
|
||||
return cmd.DumpIndexes()
|
||||
case "snapshots":
|
||||
return printSnapshots(repo, os.Stdout)
|
||||
case "trees":
|
||||
@ -138,6 +164,12 @@ func (cmd CmdDump) Execute(args []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("\nindexes:\n")
|
||||
err = cmd.DumpIndexes()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("\nindex:\n")
|
||||
|
||||
err = repo.Index().Dump(os.Stdout)
|
||||
|
Loading…
Reference in New Issue
Block a user