rdiff-backup-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [rdiff-backup-users] More newby Qs: list of changed files, server-si


From: Ben Escoto
Subject: Re: [rdiff-backup-users] More newby Qs: list of changed files, server-side diffs
Date: Fri, 22 Nov 2002 00:24:51 -0800

>>>>> "BB" == Bud P Bruegger <address@hidden>
>>>>> wrote the following on Thu, 21 Nov 2002 20:34:12 +0100

  BB> I probably wip up a quick script that does it (using find as you
  BB> suggest).  I looked through the source to see what it takes to
  BB> implement it as part of rdiff-backup -- but it seems to take
  BB> some effort of learning how to move...

Sorry, could you rephrase the last clause; I'm not sure I understand.
But anyway, just to avoid duplication of effort, I just hacked
together a --list-changed-since option which may do what you want.
See the attached patches.

  BB> BTW, I'm asking some of these questions since I may write a web
  BB> frontend for easy restoring of files..

Someone expressed a desire to do this before (that is why I added
--parsable-output) but I never heard from them.  Let me know if you
need anything.

  BB> I have to check with my users, but if they want it, I may
  BB> contribute

If you plan on doing anything substantial, let me know and I will try
to move the CVS to Savannah to make things more convenient.  I've been
meaning to do this but there is a bit of work to be done first.

  BB> ok, so that is OS dependent but works if I read it in as python
  BB> time on the same platform...

Would some other format be better?  I'm not sure anyone uses
--parsable-output.  The plan was that the format could/would be
altered as it became clearer exactly what data various frontends
needed and how it was most convenient to relay this data.  The plan
got put on hold a while because the 3rd party frontends didn't
materialize, but we could resume where we left off.


-- 
Ben Escoto

Index: Main.py
===================================================================
RCS file: /home/ben/prog/CVS/rdiff-backup/src/Main.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Main.py     17 Nov 2002 03:05:23 -0000      1.10
+++ Main.py     22 Nov 2002 08:07:01 -0000      1.11
@@ -10,6 +10,7 @@
 
 """Start (and end) here - read arguments, set global settings, etc."""
 
+from __future__ import generators
 import getopt, sys, re
 from log import *
 from lazy import *
@@ -48,13 +49,13 @@
                  "exclude-regexp=", "exclude-special-files", "force",
                  "include=", "include-filelist=", "include-filelist-stdin",
                  "include-globbing-filelist=", "include-regexp=",
-                 "list-increments", "mirror-only", "no-compression",
-                 "no-compression-regexp=", "no-hard-links", "no-resume",
-                 "null-separator", "parsable-output", "print-statistics",
-                 "quoting-char=", "remote-cmd=", "remote-schema=",
-                 "remove-older-than=", "restore-as-of=", "restrict=",
-                 "restrict-read-only=", "restrict-update-only=", "resume",
-                 "resume-window=", "server", "sleep-ratio=",
+                 "list-changed-since=", "list-increments", "mirror-only",
+                 "no-compression", "no-compression-regexp=", "no-hard-links",
+                 "no-resume", "null-separator", "parsable-output",
+                 "print-statistics", "quoting-char=", "remote-cmd=",
+                 "remote-schema=", "remove-older-than=", "restore-as-of=",
+                 "restrict=", "restrict-read-only=", "restrict-update-only=",
+                 "resume", "resume-window=", "server", "sleep-ratio=",
                  "ssh-no-compression", "terminal-verbosity=", "test-server",
                  "verbosity=", "version", "windows-mode",
                  "windows-time-format"])
@@ -101,6 +102,8 @@
                        select_opts.append((opt, arg))
                        select_files.append(sel_fl(arg))
                elif opt == "--include-regexp": select_opts.append((opt, arg))
+               elif opt == "--list-changed-since":
+                       restore_timestr, action = arg, "list-changed-since"
                elif opt == "-l" or opt == "--list-increments":
                        action = "list-increments"
                elif opt == "-m" or opt == "--mirror-only": action = "mirror"
@@ -177,7 +180,8 @@
                                  action == "restore-as-of"):
                commandline_error("Two arguments are required (source, 
destination).")
        if l == 2 and (action == "list-increments" or
-                                  action == "remove-older-than"):
+                                  action == "remove-older-than" or
+                                  action == "list-changed-since"):
                commandline_error("Only use one argument, "
                                                  "the root of the backup 
directory")
        if l > 2 and action != "calculate-average":
@@ -217,6 +221,7 @@
        elif action == "restore-as-of": RestoreAsOf(rps[0], rps[1])
        elif action == "mirror": Mirror(rps[0], rps[1])
        elif action == "test-server": SetConnections.TestConnections()
+       elif action == "list-changed-since": ListChangedSince(rps[0])
        elif action == "list-increments": ListIncrements(rps[0])
        elif action == "remove-older-than": RemoveOlderThan(rps[0])
        elif action == "calculate-average": CalculateAverage(rps)
@@ -534,4 +539,26 @@
                Log("Deleting increment at time:\n" + inc_pretty_time, 3)
        else: Log("Deleting increments at times:\n" + inc_pretty_time, 3)
        Manage.delete_earlier_than(datadir, time)
+
+
+def ListChangedSince(rp):
+       """List all the files under rp that have changed since restoretime"""
+       try: rest_time = Time.genstrtotime(restore_timestr)
+       except Time.TimeException, exc: Log.FatalError(str(exc))
+       mirror_root, index = restore_get_root(rp)
+       Globals.rbdir = datadir = mirror_root.append_path("rdiff-backup-data")
+       mirror_time = Restore.get_mirror_time()
+
+       def get_rids_recursive(rid):
+               """Yield all the rids under rid that have inc newer than 
rest_time"""
+               yield rid
+               for sub_rid in Restore.yield_rids(rid, rest_time, mirror_time):
+                       for sub_sub_rid in get_rids_recursive(sub_rid): yield 
sub_sub_rid
+
+       inc_rpath = datadir.append_path('increments', index)
+       inc_list = Restore.get_inclist(inc_rpath)
+       root_rid = RestoreIncrementData(index, inc_rpath, inc_list)
+       for rid in get_rids_recursive(root_rid):
+               if rid.inc_list: print "/".join(rid.index)
+
 
Index: Security.py
===================================================================
RCS file: /home/ben/prog/CVS/rdiff-backup/src/Security.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Security.py 18 Aug 2002 17:43:20 -0000      1.4
+++ Security.py 22 Nov 2002 08:07:01 -0000      1.5
@@ -85,7 +85,8 @@
                        sec_level = "all"
                        rdir = getpath(cp2)
        elif (action == "test-server" or action == "list-increments" or
-                 action == "calculate-average" or action == 
"remove-older-than"):
+                 action == "list-changed-since" or action ==
+                 "calculate-average" or action == "remove-older-than"):
                sec_level = "minimal"
                rdir = tempfile.gettempdir()
        else: assert 0, "Unknown action %s" % action

Attachment: pgp7nGMA0aJ2t.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]