From: Brian Warner Date: Wed, 18 Nov 2009 19:28:13 +0000 (-0800) Subject: Use DIR-IMM and t=mkdir-immutable for "tahoe backup", for #828 X-Git-Url: https://git.rkrishnan.org/%5B/frontends/statistics?a=commitdiff_plain;h=6e7fb1006db71efa11d3986588f5b528e357b404;p=tahoe-lafs%2Ftahoe-lafs.git Use DIR-IMM and t=mkdir-immutable for "tahoe backup", for #828 --- diff --git a/docs/frontends/CLI.txt b/docs/frontends/CLI.txt index 4fbb7e5c..5f601f9d 100644 --- a/docs/frontends/CLI.txt +++ b/docs/frontends/CLI.txt @@ -336,16 +336,17 @@ tahoe mv tahoe:uploaded.txt fun:uploaded.txt tahoe backup ~ work:backups This command performs a full versioned backup of every file and directory - underneath your "~" home directory, placing a read-only timestamped snapshot - in e.g. work:backups/Archives/2009-02-06_04:00:05Z/ (note that the timestamp - is in UTC, hence the "Z" suffix), and a link to the latest snapshot in - work:backups/Latest/ . This command will use a small SQLite database known - as the "backupdb", stored in ~/.tahoe/private/backupdb.sqlite, to remember - which local files have been backed up already, and will avoid uploading - files that have already been backed up. It compares timestamps and filesizes - when making this comparison. The "tahoe backup" command also shares - directories with the previous backup when nothing has changed, to run faster - and to reduce the number of directories created. + underneath your "~" home directory, placing an immutable timestamped + snapshot in e.g. work:backups/Archives/2009-02-06_04:00:05Z/ (note that the + timestamp is in UTC, hence the "Z" suffix), and a link to the latest + snapshot in work:backups/Latest/ . This command will use a small SQLite + database known as the "backupdb", stored in + ~/.tahoe/private/backupdb.sqlite, to remember which local files have been + backed up already, and will avoid uploading files that have already been + backed up. It compares timestamps and filesizes when making this comparison. + The "tahoe backup" command also shares directories with the previous backup + when nothing has changed, to run faster and to reduce the number of + directories created. tahoe backup --exclude=*~ ~ work:backups diff --git a/src/allmydata/scripts/tahoe_backup.py b/src/allmydata/scripts/tahoe_backup.py index c8d5ea35..145106ee 100644 --- a/src/allmydata/scripts/tahoe_backup.py +++ b/src/allmydata/scripts/tahoe_backup.py @@ -83,21 +83,18 @@ def get_local_metadata(path): return metadata def mkdir(contents, options): - url = options['node-url'] + "uri?t=mkdir" - resp = do_http("POST", url) - if resp.status < 200 or resp.status >= 300: - raiseHTTPError("error during mkdir", resp) - dircap = str(resp.read().strip()) - url = options['node-url'] + "uri/%s?t=set_children" % urllib.quote(dircap) - body = dict([ (childname, (contents[childname][0], + kids = dict([ (childname, (contents[childname][0], {"ro_uri": contents[childname][1], "metadata": contents[childname][2], })) for childname in contents ]) - resp = do_http("POST", url, simplejson.dumps(body)) - if resp.status != 200: - raiseHTTPError("error during set_children", resp) + body = simplejson.dumps(kids) + url = options['node-url'] + "uri?t=mkdir-immutable" + resp = do_http("POST", url, body) + if resp.status < 200 or resp.status >= 300: + raiseHTTPError("error during mkdir", resp) + dircap = str(resp.read().strip()) return dircap def put_child(dirurl, childname, childcap): diff --git a/src/allmydata/test/test_cli.py b/src/allmydata/test/test_cli.py index 56a83470..58754b88 100644 --- a/src/allmydata/test/test_cli.py +++ b/src/allmydata/test/test_cli.py @@ -998,11 +998,16 @@ class Backup(GridTestMixin, CLITestMixin, StallMixin, unittest.TestCase): self.failUnlessEqual(dr, 0) d.addCallback(_check0) - d.addCallback(lambda res: self.do_cli("ls", "tahoe:backups")) + d.addCallback(lambda res: self.do_cli("ls", "--uri", "tahoe:backups")) def _check1((rc, out, err)): self.failUnlessEqual(err, "") self.failUnlessEqual(rc, 0) - self.failUnlessEqual(sorted(out.split()), ["Archives", "Latest"]) + lines = out.split("\n") + children = dict([line.split() for line in lines if line]) + latest_uri = children["Latest"] + self.failUnless(latest_uri.startswith("URI:DIR2-CHK:"), latest_uri) + childnames = children.keys() + self.failUnlessEqual(sorted(childnames), ["Archives", "Latest"]) d.addCallback(_check1) d.addCallback(lambda res: self.do_cli("ls", "tahoe:backups/Latest")) def _check2((rc, out, err)):