Commit 90df2383 authored by ben's avatar ben

Changes, only one I remember is adding --list-changed-since


git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup@231 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
parent be022168
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
"""Start (and end) here - read arguments, set global settings, etc.""" """Start (and end) here - read arguments, set global settings, etc."""
from __future__ import generators
import getopt, sys, re import getopt, sys, re
from log import * from log import *
from lazy import * from lazy import *
...@@ -48,13 +49,13 @@ def parse_cmdlineoptions(arglist): ...@@ -48,13 +49,13 @@ def parse_cmdlineoptions(arglist):
"exclude-regexp=", "exclude-special-files", "force", "exclude-regexp=", "exclude-special-files", "force",
"include=", "include-filelist=", "include-filelist-stdin", "include=", "include-filelist=", "include-filelist-stdin",
"include-globbing-filelist=", "include-regexp=", "include-globbing-filelist=", "include-regexp=",
"list-increments", "mirror-only", "no-compression", "list-changed-since=", "list-increments", "mirror-only",
"no-compression-regexp=", "no-hard-links", "no-resume", "no-compression", "no-compression-regexp=", "no-hard-links",
"null-separator", "parsable-output", "print-statistics", "no-resume", "null-separator", "parsable-output",
"quoting-char=", "remote-cmd=", "remote-schema=", "print-statistics", "quoting-char=", "remote-cmd=",
"remove-older-than=", "restore-as-of=", "restrict=", "remote-schema=", "remove-older-than=", "restore-as-of=",
"restrict-read-only=", "restrict-update-only=", "resume", "restrict=", "restrict-read-only=", "restrict-update-only=",
"resume-window=", "server", "sleep-ratio=", "resume", "resume-window=", "server", "sleep-ratio=",
"ssh-no-compression", "terminal-verbosity=", "test-server", "ssh-no-compression", "terminal-verbosity=", "test-server",
"verbosity=", "version", "windows-mode", "verbosity=", "version", "windows-mode",
"windows-time-format"]) "windows-time-format"])
...@@ -101,6 +102,8 @@ def parse_cmdlineoptions(arglist): ...@@ -101,6 +102,8 @@ def parse_cmdlineoptions(arglist):
select_opts.append((opt, arg)) select_opts.append((opt, arg))
select_files.append(sel_fl(arg)) select_files.append(sel_fl(arg))
elif opt == "--include-regexp": select_opts.append((opt, 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": elif opt == "-l" or opt == "--list-increments":
action = "list-increments" action = "list-increments"
elif opt == "-m" or opt == "--mirror-only": action = "mirror" elif opt == "-m" or opt == "--mirror-only": action = "mirror"
...@@ -177,7 +180,8 @@ def set_action(): ...@@ -177,7 +180,8 @@ def set_action():
action == "restore-as-of"): action == "restore-as-of"):
commandline_error("Two arguments are required (source, destination).") commandline_error("Two arguments are required (source, destination).")
if l == 2 and (action == "list-increments" or 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, " commandline_error("Only use one argument, "
"the root of the backup directory") "the root of the backup directory")
if l > 2 and action != "calculate-average": if l > 2 and action != "calculate-average":
...@@ -217,6 +221,7 @@ def take_action(rps): ...@@ -217,6 +221,7 @@ def take_action(rps):
elif action == "restore-as-of": RestoreAsOf(rps[0], rps[1]) elif action == "restore-as-of": RestoreAsOf(rps[0], rps[1])
elif action == "mirror": Mirror(rps[0], rps[1]) elif action == "mirror": Mirror(rps[0], rps[1])
elif action == "test-server": SetConnections.TestConnections() elif action == "test-server": SetConnections.TestConnections()
elif action == "list-changed-since": ListChangedSince(rps[0])
elif action == "list-increments": ListIncrements(rps[0]) elif action == "list-increments": ListIncrements(rps[0])
elif action == "remove-older-than": RemoveOlderThan(rps[0]) elif action == "remove-older-than": RemoveOlderThan(rps[0])
elif action == "calculate-average": CalculateAverage(rps) elif action == "calculate-average": CalculateAverage(rps)
...@@ -535,3 +540,25 @@ def RemoveOlderThan(rootrp): ...@@ -535,3 +540,25 @@ def RemoveOlderThan(rootrp):
else: Log("Deleting increments at times:\n" + inc_pretty_time, 3) else: Log("Deleting increments at times:\n" + inc_pretty_time, 3)
Manage.delete_earlier_than(datadir, time) 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)
...@@ -85,7 +85,8 @@ def set_security_level(action, cmdpairs): ...@@ -85,7 +85,8 @@ def set_security_level(action, cmdpairs):
sec_level = "all" sec_level = "all"
rdir = getpath(cp2) rdir = getpath(cp2)
elif (action == "test-server" or action == "list-increments" or 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" sec_level = "minimal"
rdir = tempfile.gettempdir() rdir = tempfile.gettempdir()
else: assert 0, "Unknown action %s" % action else: assert 0, "Unknown action %s" % action
......
...@@ -15,7 +15,6 @@ import types ...@@ -15,7 +15,6 @@ import types
from rpath import * from rpath import *
from lazy import * from lazy import *
class DSRPPermError(Exception): class DSRPPermError(Exception):
"""Exception used when a DSRPath can't get sufficient permissions""" """Exception used when a DSRPath can't get sufficient permissions"""
pass pass
......
...@@ -15,7 +15,6 @@ from static import * ...@@ -15,7 +15,6 @@ from static import *
from statistics import * from statistics import *
from lazy import * from lazy import *
class Inc: class Inc:
"""Class containing increment functions""" """Class containing increment functions"""
def Increment_action(new, mirror, incpref): def Increment_action(new, mirror, incpref):
...@@ -322,3 +321,4 @@ from rpath import * ...@@ -322,3 +321,4 @@ from rpath import *
from robust import * from robust import *
from rorpiter import * from rorpiter import *
import Globals, Time, MiscStats import Globals, Time, MiscStats
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
from __future__ import generators from __future__ import generators
import os, stat, types import os, stat, types
from static import * from static import *
import psyco
class Iter: class Iter:
"""Hold static methods for the manipulation of lazy iterators""" """Hold static methods for the manipulation of lazy iterators"""
...@@ -291,6 +291,8 @@ class IterTreeReducer: ...@@ -291,6 +291,8 @@ class IterTreeReducer:
self.index = index self.index = index
return 1 return 1
psyco.bind(IterTreeReducer)
class ITRBranch: class ITRBranch:
"""Helper class for IterTreeReducer below """Helper class for IterTreeReducer below
...@@ -355,4 +357,3 @@ class ITRBranch: ...@@ -355,4 +357,3 @@ class ITRBranch:
# Put at bottom to prevent (viciously) circular module dependencies # Put at bottom to prevent (viciously) circular module dependencies
from robust import * from robust import *
from log import * from log import *
...@@ -40,7 +40,6 @@ able to narrow down the possibilities. ...@@ -40,7 +40,6 @@ able to narrow down the possibilities.
import tempfile, errno, signal, cPickle, C import tempfile, errno, signal, cPickle, C
from static import * from static import *
class RobustAction: class RobustAction:
"""Represents a file operation to be accomplished later""" """Represents a file operation to be accomplished later"""
def __init__(self, init_thunk, final_func, error_handler): def __init__(self, init_thunk, final_func, error_handler):
......
...@@ -19,7 +19,6 @@ from robust import * ...@@ -19,7 +19,6 @@ from robust import *
from iterfile import * from iterfile import *
import Globals, Rdiff, Hardlink import Globals, Rdiff, Hardlink
class RORPIterException(Exception): pass class RORPIterException(Exception): pass
class RORPIter: class RORPIter:
......
...@@ -283,7 +283,7 @@ class Select: ...@@ -283,7 +283,7 @@ class Select:
elif opt == "--include-regexp": elif opt == "--include-regexp":
self.add_selection_func(self.regexp_get_sf(arg, 1)) self.add_selection_func(self.regexp_get_sf(arg, 1))
else: assert 0, "Bad selection option %s" % opt else: assert 0, "Bad selection option %s" % opt
except SelectError, e: self.parse_catch_error(e) except IOError: pass#SelectError, e: self.parse_catch_error(e)
assert filelists_index == len(filelists) assert filelists_index == len(filelists)
self.parse_last_excludes() self.parse_last_excludes()
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
"""Start (and end) here - read arguments, set global settings, etc.""" """Start (and end) here - read arguments, set global settings, etc."""
from __future__ import generators
import getopt, sys, re import getopt, sys, re
from log import * from log import *
from lazy import * from lazy import *
...@@ -48,13 +49,13 @@ def parse_cmdlineoptions(arglist): ...@@ -48,13 +49,13 @@ def parse_cmdlineoptions(arglist):
"exclude-regexp=", "exclude-special-files", "force", "exclude-regexp=", "exclude-special-files", "force",
"include=", "include-filelist=", "include-filelist-stdin", "include=", "include-filelist=", "include-filelist-stdin",
"include-globbing-filelist=", "include-regexp=", "include-globbing-filelist=", "include-regexp=",
"list-increments", "mirror-only", "no-compression", "list-changed-since=", "list-increments", "mirror-only",
"no-compression-regexp=", "no-hard-links", "no-resume", "no-compression", "no-compression-regexp=", "no-hard-links",
"null-separator", "parsable-output", "print-statistics", "no-resume", "null-separator", "parsable-output",
"quoting-char=", "remote-cmd=", "remote-schema=", "print-statistics", "quoting-char=", "remote-cmd=",
"remove-older-than=", "restore-as-of=", "restrict=", "remote-schema=", "remove-older-than=", "restore-as-of=",
"restrict-read-only=", "restrict-update-only=", "resume", "restrict=", "restrict-read-only=", "restrict-update-only=",
"resume-window=", "server", "sleep-ratio=", "resume", "resume-window=", "server", "sleep-ratio=",
"ssh-no-compression", "terminal-verbosity=", "test-server", "ssh-no-compression", "terminal-verbosity=", "test-server",
"verbosity=", "version", "windows-mode", "verbosity=", "version", "windows-mode",
"windows-time-format"]) "windows-time-format"])
...@@ -101,6 +102,8 @@ def parse_cmdlineoptions(arglist): ...@@ -101,6 +102,8 @@ def parse_cmdlineoptions(arglist):
select_opts.append((opt, arg)) select_opts.append((opt, arg))
select_files.append(sel_fl(arg)) select_files.append(sel_fl(arg))
elif opt == "--include-regexp": select_opts.append((opt, 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": elif opt == "-l" or opt == "--list-increments":
action = "list-increments" action = "list-increments"
elif opt == "-m" or opt == "--mirror-only": action = "mirror" elif opt == "-m" or opt == "--mirror-only": action = "mirror"
...@@ -177,7 +180,8 @@ def set_action(): ...@@ -177,7 +180,8 @@ def set_action():
action == "restore-as-of"): action == "restore-as-of"):
commandline_error("Two arguments are required (source, destination).") commandline_error("Two arguments are required (source, destination).")
if l == 2 and (action == "list-increments" or 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, " commandline_error("Only use one argument, "
"the root of the backup directory") "the root of the backup directory")
if l > 2 and action != "calculate-average": if l > 2 and action != "calculate-average":
...@@ -217,6 +221,7 @@ def take_action(rps): ...@@ -217,6 +221,7 @@ def take_action(rps):
elif action == "restore-as-of": RestoreAsOf(rps[0], rps[1]) elif action == "restore-as-of": RestoreAsOf(rps[0], rps[1])
elif action == "mirror": Mirror(rps[0], rps[1]) elif action == "mirror": Mirror(rps[0], rps[1])
elif action == "test-server": SetConnections.TestConnections() elif action == "test-server": SetConnections.TestConnections()
elif action == "list-changed-since": ListChangedSince(rps[0])
elif action == "list-increments": ListIncrements(rps[0]) elif action == "list-increments": ListIncrements(rps[0])
elif action == "remove-older-than": RemoveOlderThan(rps[0]) elif action == "remove-older-than": RemoveOlderThan(rps[0])
elif action == "calculate-average": CalculateAverage(rps) elif action == "calculate-average": CalculateAverage(rps)
...@@ -535,3 +540,25 @@ def RemoveOlderThan(rootrp): ...@@ -535,3 +540,25 @@ def RemoveOlderThan(rootrp):
else: Log("Deleting increments at times:\n" + inc_pretty_time, 3) else: Log("Deleting increments at times:\n" + inc_pretty_time, 3)
Manage.delete_earlier_than(datadir, time) 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)
...@@ -85,7 +85,8 @@ def set_security_level(action, cmdpairs): ...@@ -85,7 +85,8 @@ def set_security_level(action, cmdpairs):
sec_level = "all" sec_level = "all"
rdir = getpath(cp2) rdir = getpath(cp2)
elif (action == "test-server" or action == "list-increments" or 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" sec_level = "minimal"
rdir = tempfile.gettempdir() rdir = tempfile.gettempdir()
else: assert 0, "Unknown action %s" % action else: assert 0, "Unknown action %s" % action
......
...@@ -15,7 +15,6 @@ import types ...@@ -15,7 +15,6 @@ import types
from rpath import * from rpath import *
from lazy import * from lazy import *
class DSRPPermError(Exception): class DSRPPermError(Exception):
"""Exception used when a DSRPath can't get sufficient permissions""" """Exception used when a DSRPath can't get sufficient permissions"""
pass pass
......
...@@ -15,7 +15,6 @@ from static import * ...@@ -15,7 +15,6 @@ from static import *
from statistics import * from statistics import *
from lazy import * from lazy import *
class Inc: class Inc:
"""Class containing increment functions""" """Class containing increment functions"""
def Increment_action(new, mirror, incpref): def Increment_action(new, mirror, incpref):
...@@ -322,3 +321,4 @@ from rpath import * ...@@ -322,3 +321,4 @@ from rpath import *
from robust import * from robust import *
from rorpiter import * from rorpiter import *
import Globals, Time, MiscStats import Globals, Time, MiscStats
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
from __future__ import generators from __future__ import generators
import os, stat, types import os, stat, types
from static import * from static import *
import psyco
class Iter: class Iter:
"""Hold static methods for the manipulation of lazy iterators""" """Hold static methods for the manipulation of lazy iterators"""
...@@ -291,6 +291,8 @@ class IterTreeReducer: ...@@ -291,6 +291,8 @@ class IterTreeReducer:
self.index = index self.index = index
return 1 return 1
psyco.bind(IterTreeReducer)
class ITRBranch: class ITRBranch:
"""Helper class for IterTreeReducer below """Helper class for IterTreeReducer below
...@@ -355,4 +357,3 @@ class ITRBranch: ...@@ -355,4 +357,3 @@ class ITRBranch:
# Put at bottom to prevent (viciously) circular module dependencies # Put at bottom to prevent (viciously) circular module dependencies
from robust import * from robust import *
from log import * from log import *
...@@ -40,7 +40,6 @@ able to narrow down the possibilities. ...@@ -40,7 +40,6 @@ able to narrow down the possibilities.
import tempfile, errno, signal, cPickle, C import tempfile, errno, signal, cPickle, C
from static import * from static import *
class RobustAction: class RobustAction:
"""Represents a file operation to be accomplished later""" """Represents a file operation to be accomplished later"""
def __init__(self, init_thunk, final_func, error_handler): def __init__(self, init_thunk, final_func, error_handler):
......
...@@ -19,7 +19,6 @@ from robust import * ...@@ -19,7 +19,6 @@ from robust import *
from iterfile import * from iterfile import *
import Globals, Rdiff, Hardlink import Globals, Rdiff, Hardlink
class RORPIterException(Exception): pass class RORPIterException(Exception): pass
class RORPIter: class RORPIter:
......
...@@ -283,7 +283,7 @@ class Select: ...@@ -283,7 +283,7 @@ class Select:
elif opt == "--include-regexp": elif opt == "--include-regexp":
self.add_selection_func(self.regexp_get_sf(arg, 1)) self.add_selection_func(self.regexp_get_sf(arg, 1))
else: assert 0, "Bad selection option %s" % opt else: assert 0, "Bad selection option %s" % opt
except SelectError, e: self.parse_catch_error(e) except IOError: pass#SelectError, e: self.parse_catch_error(e)
assert filelists_index == len(filelists) assert filelists_index == len(filelists)
self.parse_last_excludes() self.parse_last_excludes()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment