#2135 new enhancement

Add --print-uri option to "tahoe backup" to dump resulting backup URI

Reported by: amontero Owned by: amontero
Priority: normal Milestone: soon
Component: code-frontend-cli Version: 1.10.0
Keywords: tahoe-backup backup test-needed easy Cc: remyroy@…
Launchpad Bug:

Description (last modified by amontero)

When I do [scripted] backups to my grid, I would like to collect the resulting backup root URI to a file. I've added a "--printcap" option to "tahoe backup" to do it and works good, so far.

Off by default for backwards compatibility. Comes to mind someone using "tahoe backup" from a script piping the output to a file and mailing it. Other than this, looks like an trivial addition.

Code is at: https://github.com/tahoe-lafs/tahoe-lafs/pull/76

Change History (17)

comment:1 Changed at 2013-12-14T20:58:44Z by amontero

Also you can accomplish David Sarah's case at ticket:835#10 with this one-liner:

$ tahoe backup --ignore-timestamps --printcap ~/Documents/ `tahoe mkdir`

The mkdir'ed directory URI is completely ignored, we will just keep the --printcap'ed URI as the *immutable* backup root.

Last edited at 2013-12-14T20:59:43Z by amontero (previous) (diff)

comment:2 Changed at 2013-12-14T21:13:12Z by amontero

  • Description modified (diff)

comment:3 Changed at 2013-12-15T23:41:45Z by markberger

+1

It might be good to add this option to the docs in frontends/CLI.rst.

comment:4 follow-up: Changed at 2013-12-16T11:25:58Z by amontero

Also a doubt: Better to print the URI alone with no surrounding text (as it's done in "tahoe put" or "tahoe mkdir")? If there was a --quiet option it would make sense, but printed along the backup summary, I think it's not worth it.

comment:5 in reply to: ↑ 4 Changed at 2013-12-16T18:39:41Z by daira

Replying to amontero:

Also a doubt: Better to print the URI alone with no surrounding text (as it's done in "tahoe put" or "tahoe mkdir")? If there was a --quiet option it would make sense, but printed along the backup summary, I think it's not worth it.

Yes, that's a problem for use in scripts. Maybe print the URI alone on stdout, and the backup summary on stderr when --printcap is used?

comment:6 Changed at 2013-12-16T19:51:15Z by amontero

Great idea, +1. Also, it's low hanging fruit :)

Done it, stripped the "Resulting backup..." string. Sample console output below.

 4 files uploaded (0 reused), 0 files skipped, 0 directories created (1 reused), 0 directories skipped
 backup done, elapsed time: 0:00:18
URI:DIR2-CHK:35ge[...]3gze:rij[...]nka:1:2:1074

It's OK to also redirect the more verbose messages to stderr?

comment:7 Changed at 2013-12-16T19:56:12Z by amontero

I mean this one:

            if self.verbosity >= 2:
                print >>stdout, (" %d files checked, %d directories checked"
                                 % (self.files_checked,
                                    self.directories_checked))

comment:8 Changed at 2013-12-17T11:22:00Z by daira

Yes.

comment:9 Changed at 2013-12-17T12:09:52Z by amontero

As discussed in IRC:

  • Renamed --printcap to --print-uri
  • Tentatively adding -U as option shortcut (-u conflicts with --node-url)
  • All verbosity messages previously sent to stdout now are sent to stderr. Only resulting backup URI goes to stdout.

Updated the pull request accordingly for review.

Also, I proposed Daira to make --print-uri the default behavior to make it consistent with "tahoe put" and "tahoe mkdir". However, this could be a security issue for existing scripts. Needs further discussion.

comment:10 Changed at 2013-12-17T12:13:14Z by amontero

  • Summary changed from Add --printcap option to "tahoe backup" to dump resulting backup URI to Add --print-uri option to "tahoe backup" to dump resulting backup URI

comment:11 Changed at 2013-12-17T19:18:05Z by daira

  • Keywords review-needed added
  • Owner set to daira
  • Status changed from new to assigned

comment:12 Changed at 2013-12-23T22:28:23Z by amontero

  • Keywords easy added

comment:13 Changed at 2014-03-19T01:06:26Z by remyroy

  • Owner changed from daira to remyroy
  • Status changed from assigned to new

I'll review this patch/pull request.

comment:14 Changed at 2014-03-19T01:06:36Z by remyroy

  • Status changed from new to assigned

comment:15 Changed at 2014-03-19T16:17:02Z by remyroy

  • Cc remyroy@… added
  • Keywords test-needed added; review-needed removed
  • Owner changed from remyroy to amontero
  • Status changed from assigned to new

Great code so far. I feel this would be quite useful for scripting backups.

There is still 2 failing backup related tests from this patch/pull request. The cli--tahoe-backup--dump-backup-dircap-stdout--tests branch from https://github.com/pataquets/tahoe-lafs/ seems to have some attempt at fixing those failing tests but they are still present.

There should also be an additional test in allmydata.test.test_cli.Backup to test this new command option.

Reassigning back to amontero for patch changes.

comment:16 Changed at 2014-04-15T00:59:08Z by daira

This could potentially get into 1.11 if the tests were fixed, but the core developers will be focussing on other things, so that depends on amontero.

comment:17 Changed at 2014-04-15T00:59:49Z by daira

  • Milestone changed from undecided to soon
Note: See TracTickets for help on using tickets.