def patch(cls, dest_rpath, source_diffiter, start_index = ()): """Patch dest_rpath with an rorpiter of diffs""" ITR = rorpiter.IterTreeReducer(PatchITRB, [dest_rpath, cls.CCPP]) for diff in rorpiter.FillInIter(source_diffiter, dest_rpath): log.Log("Processing changed file " + diff.get_indexpath(), 5) ITR(diff.index, diff) ITR.Finish() cls.CCPP.close() dest_rpath.setdata()
def patch_and_increment(cls, dest_rpath, source_diffiter, inc_rpath): """Patch dest_rpath with rorpiter of diffs and write increments""" ITR = rorpiter.IterTreeReducer(IncrementITRB, [dest_rpath, inc_rpath, cls.CCPP]) for diff in rorpiter.FillInIter(source_diffiter, dest_rpath): log.Log("Processing changed file " + diff.get_indexpath(), 5) ITR(diff.index, diff) ITR.Finish() cls.CCPP.close() dest_rpath.setdata()
def FilterIter(self, rorp_iter): """Filter rorp_iter using Select below, removing excluded rorps""" def getrpiter(rorp_iter): """Return rp iter by adding indicies of rorp_iter to self.rpath""" for rorp in rorp_iter: yield rpath.RPath(self.rpath.conn, self.rpath.base, rorp.index, rorp.data) ITR = rorpiter.IterTreeReducer(FilterIterITRB, [self]) for rp in rp_iter: ITR(rp.index, rp) ITR.Finish()
def __init__(self, select, rorp_iter): """Constructor Input is the Select object to use and the iter of rorps to be filtered. The rorps will be converted to rps using the Select base. """ self.rorp_iter = rorp_iter self.base_rp = select.rpath self.stored_rorps = [] self.ITR = rorpiter.IterTreeReducer(FilterIterITRB, [select.Select, self.stored_rorps]) self.itr_finished = 0
def patch(cls, target, diff_iter): """Patch target with the diffs from the mirror side This function and the associated ITRB is similar to the patching code in backup.py, but they have different error correction requirements, so it seemed easier to just repeat it all in this module. """ ITR = rorpiter.IterTreeReducer(PatchITRB, [target]) for diff in rorpiter.FillInIter(diff_iter, target): log.Log("Processing changed file " + diff.get_indexpath(), 5) ITR(diff.index, diff) ITR.Finish() target.setdata()
def Regress(mirror_rp): """Bring mirror and inc directory back to regress_to_time Also affects the rdiff-backup-data directory, so Globals.rbdir should be set. Regress should only work one step at a time (i.e. don't "regress" through two separate backup sets. This function should be run locally to the rdiff-backup-data directory. """ inc_rpath = Globals.rbdir.append_path("increments") assert mirror_rp.index == () and inc_rpath.index == () assert mirror_rp.isdir() and inc_rpath.isdir() assert mirror_rp.conn is inc_rpath.conn is Globals.local_connection manager, former_current_mirror_rp = set_regress_time() set_restore_times() regress_rbdir(manager) ITR = rorpiter.IterTreeReducer(RegressITRB, []) for rf in iterate_meta_rfs(mirror_rp, inc_rpath): ITR(rf.index, rf) ITR.Finish() if former_current_mirror_rp: C.sync() # Sync first, since we are marking dest dir as good now former_current_mirror_rp.delete()