bum_rdiff
index
../bum_rdiff.py

Rdiff-backup based backup method
 
This module defines all methods required to successfully backup a file using the
rdiff-backup method.
 
Expected roadmap:
    * The method works this way:
        * get the signature for a given file that has been modified (of course
          the original unmodified version should be in the target directory)
          using the SigFile method.
        * Apply the modified file signature to the original file to obtain a
          diff version using the DeltaFile method and store the diff file.
        * Whenever we want to get the original file backup, apply the diff to
          modified version: this will return the original version.
        * This method always keep the last version of the file and stores the
          deltas of previous versions so that users can restore the prior
          incarnations of the file whenever they want.
    * To make this method fit our established plan, we need to take in
      consideration the defined transport for the task: if the target directory
      is local, we can do the work without transfering information. In case the
      target is in a remote device or placed in a mounted device we need to
      transfer as little information as posible.
    * A suggested plan could be the following:
        * if local transport:
            * perform the DeltaFile with two file-like objects locally.
            * save the diff file before replacing the original file with the
              modified one: we will have the last version and then all deltas
              that can be use to patch this last version in reverse until user
              gets the version she/he wants.
        * if remote transport:
            * with every last version of a file, we store its signature (of
              course, we're talking about the remote target), compressed.
            * If the file in the local side changed, we connect and request
              signature.
            * Server sends it and we decompressed it.
            * Apply this signature to the modified local version and get a
              Delta File.
            * Compress the Delta, send it to the remote server and discard the
              received signature.
            * Patch the server version with the Delta File (all described until
              now is according to Martin Pool's paper "rdiff 1.0pre DRAFT, 20th
              July 2004") and generate the SigFile and compress it (this
              compressed sigfile will be needed the next time to backup),
              saving a temporal copy of the original version.
            * Apply DeltaFile to the temporal copy of the original file and the
              signature of our new modified version.
            * Get a diff we can now store as an incremental reverse version.
            * Discard the temporal original version.
 
For more on rdiff-backup please see: http://www.nongnu.org/rdiff-backup/
For more on librsync / rdiff please see: http://librsync.sourcefrog.net/

 
Modules
       
rdiff_backup.Globals
rdiff_backup.Rdiff
bzrlib.errors
rdiff_backup.librsync
os
rdiff_backup.rpath
shutil
tempfile

 
Classes
       
exceptions.Exception(exceptions.BaseException)
BumRdiffError

 
class BumRdiffError(exceptions.Exception)
    
Method resolution order:
BumRdiffError
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors defined here:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object at 0x8141680>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception message

 
Functions
       
delta(signature, file_, compression_method=None)
Generator to obtain the diff between a file and its counterpart's
signature. File will be closed when its done
Parameters:
    file_: the file-like object
    compression_method: the compression algorithm used to return the
    result. It supports all codecs supported by Python. Options are: zip,
    bz2 and None.
local_backup(modified, original, delta_name, transport, to, compress_method=None)
Generate the delta of a file, using the modified file's signature and
the prior version file. This method will:
    * generate the delta and saving it using delta_name as name of the
      file.
    * replace the original file with the modified version
    * save the compressed signature of the modified file
Parameters:
    modified: the name of the "from" (a.k.a. to-backup) version of the
    file.
    original: the name of the "to" (a.k.a. to-be-replaced) version of
    the file
    delta_name: the full path to the file we'll use to save the delta we'll
    generate from the last two parameters
    transport: a bzrlib.Transport instance
    to: the location to put the file, relative to transport.base
    compress_method: in case of need user can select a compression method
    to apply to the delta file and to the signature file. The options are
    the ones that Python has supported builtin codecs (see
    http://docs.python.org/lib/standard-encodings.html#standard-encodings)
patch(basis_file, delta_file)
Generator to obtain the results of patching a file
remote_backup(modified, original, delta_name, compress_method=None, signature=None)
FIXME: write doc
sign(infile, compression_method=None)
Given a file-like object will get its signature and return it.
The object will be closed after calculating the signature
Parameters:
    infile: the file-like object
    compression_method: the compression algorithm used to return the
    result. It supports all codecs supported by Python. Options are: zip,
    bz2 and None.