mirror of
https://github.com/restic/restic.git
synced 2026-08-25 15:03:17 +00:00
cmd/copy: Prefix hostname to snapshot display output
This change better resembles the output generated by `Snapshot.String()`, which includes both username and hostname. Closes #4506 Before: ``` $ restic copy --from-repo /srv/restic-repo repository 3666882b opened (version 2, compression level auto) repository 0085c387 opened (version 2, compression level auto) created new cache in /home/mike/.cache/restic [0:00] 100.00% 1 / 1 index files loaded [0:00] 0 index files loaded snapshot 32b39a20 of [/home/mike/data] at 2023-10-21 16:01:13.979948154 -0300 -03) copy started, this may take a while... [0:00] 100.00% 1 / 1 packs copied snapshot 10331fdd saved ``` After: ``` $ restic copy --from-repo /srv/restic-repo repository 3666882b opened (version 2, compression level auto) repository 0085c387 opened (version 2, compression level auto) [0:00] 100.00% 1 / 1 index files loaded [0:00] 0 index files loaded snapshot 32b39a20 of [/home/mike/data] at 2023-10-21 16:01:13.979948154 -0300 -03 by mike@desktop) copy started, this may take a while... [0:00] 100.00% 1 / 1 packs copied snapshot a67bd1ee saved ```
This commit is contained in:
committed by
Michael Eischer
parent
634e2a46d9
commit
045aa64558
@@ -126,11 +126,12 @@ func runCopy(ctx context.Context, opts CopyOptions, gopts GlobalOptions, args []
|
||||
if sn.Original != nil {
|
||||
srcOriginal = *sn.Original
|
||||
}
|
||||
|
||||
if originalSns, ok := dstSnapshotByOriginal[srcOriginal]; ok {
|
||||
isCopy := false
|
||||
for _, originalSn := range originalSns {
|
||||
if similarSnapshots(originalSn, sn) {
|
||||
Verboseff("\nsnapshot %s of %v at %s)\n", sn.ID().Str(), sn.Paths, sn.Time)
|
||||
Verboseff("\nsnapshot %s of %v at %s by %s@%s)\n", sn.ID().Str(), sn.Paths, sn.Time, sn.Username, sn.Hostname)
|
||||
Verboseff("skipping source snapshot %s, was already copied to snapshot %s\n", sn.ID().Str(), originalSn.ID().Str())
|
||||
isCopy = true
|
||||
break
|
||||
@@ -140,7 +141,7 @@ func runCopy(ctx context.Context, opts CopyOptions, gopts GlobalOptions, args []
|
||||
continue
|
||||
}
|
||||
}
|
||||
Verbosef("\nsnapshot %s of %v at %s)\n", sn.ID().Str(), sn.Paths, sn.Time)
|
||||
Verbosef("\nsnapshot %s of %v at %s by %s@%s)\n", sn.ID().Str(), sn.Paths, sn.Time, sn.Username, sn.Hostname)
|
||||
Verbosef(" copy started, this may take a while...\n")
|
||||
if err := copyTree(ctx, srcRepo, dstRepo, visitedTrees, *sn.Tree, gopts.Quiet); err != nil {
|
||||
return err
|
||||
|
||||
@@ -207,7 +207,7 @@ func runLs(ctx context.Context, opts LsOptions, gopts GlobalOptions, args []stri
|
||||
}
|
||||
} else {
|
||||
printSnapshot = func(sn *restic.Snapshot) {
|
||||
Verbosef("snapshot %s of %v filtered by %v at %s):\n", sn.ID().Str(), sn.Paths, dirs, sn.Time)
|
||||
Verbosef("snapshot %s of %v filtered by %v at %s by %s@%s):\n", sn.ID().Str(), sn.Paths, dirs, sn.Time, sn.Username, sn.Hostname)
|
||||
}
|
||||
printNode = func(path string, node *restic.Node) {
|
||||
Printf("%s\n", formatNode(path, node, lsOptions.ListLong, lsOptions.HumanReadable))
|
||||
|
||||
@@ -144,7 +144,7 @@ func runRepairSnapshots(ctx context.Context, gopts GlobalOptions, opts RepairOpt
|
||||
|
||||
changedCount := 0
|
||||
for sn := range FindFilteredSnapshots(ctx, snapshotLister, repo, &opts.SnapshotFilter, args) {
|
||||
Verbosef("\nsnapshot %s of %v at %s)\n", sn.ID().Str(), sn.Paths, sn.Time)
|
||||
Verbosef("\nsnapshot %s of %v at %s by %s@%s)\n", sn.ID().Str(), sn.Paths, sn.Time, sn.Username, sn.Hostname)
|
||||
changed, err := filterAndReplaceSnapshot(ctx, repo, sn,
|
||||
func(ctx context.Context, sn *restic.Snapshot) (restic.ID, error) {
|
||||
return rewriter.RewriteTree(ctx, repo, "/", *sn.Tree)
|
||||
|
||||
@@ -290,7 +290,7 @@ func runRewrite(ctx context.Context, opts RewriteOptions, gopts GlobalOptions, a
|
||||
|
||||
changedCount := 0
|
||||
for sn := range FindFilteredSnapshots(ctx, snapshotLister, repo, &opts.SnapshotFilter, args) {
|
||||
Verbosef("\nsnapshot %s of %v at %s)\n", sn.ID().Str(), sn.Paths, sn.Time)
|
||||
Verbosef("\nsnapshot %s of %v at %s by %s@%s)\n", sn.ID().Str(), sn.Paths, sn.Time, sn.Username, sn.Hostname)
|
||||
changed, err := rewriteSnapshot(ctx, repo, sn, opts)
|
||||
if err != nil {
|
||||
return errors.Fatalf("unable to rewrite snapshot ID %q: %v", sn.ID().Str(), err)
|
||||
|
||||
Reference in New Issue
Block a user