btrsync.sync¶
Btrfs subvolume synchronization.
Functions
|
Get the default btrfs root used to handle protocol. |
- btrsync.sync.default_root(protocol)[source]¶
Get the default btrfs root used to handle protocol.
- Parameters
protocol – btrfs protocol to use; valid values are
'local','ssh','file', and'file-dump'.- Returns
appropriate
btrsync.sync.root.BtrfsRootsubclass factory for protocol- Raises
ValueError – if protocol is unknown
Classes
|
Base class containing logic to sync btrfs subvolumes from a source root to a destination root. |
|
Transfer class providing a mechanism for logging transfer progress. |
|
Base class implementing a transfer as required by |
- class btrsync.sync.BtrSync(src, dst, *, srckeys=None, dstkeys=None)[source]¶
Base class containing logic to sync btrfs subvolumes from a source root to a destination root.
- Parameters
src – source btrfs root (
btrsync.sync.root.BtrfsRoot-like instance)dst – destination btrfs root (
btrsync.sync.root.BtrfsRoot-like instance)srckeys – key functions to be applied to the subvolumes of src, if
Noneuse default key functionsdstkeys – key functions to be applied to the subvolumes of dst, if
Noneuse default key functions
Key functions take a subvolume as argument and return a value that is then used for equality testing. Two subvolumes are considered equal if any of their key values compare equal and are not
None. The default key functions return the UUID and received UUID of subvolumes.- static check(vol, parent)[source]¶
Return
Trueif the sync of vol with COW parent parent should proceed.
- parent(vol)[source]¶
Return the COW parent of vol to be used as basis for incremental send, or
Noneif unavailable.
- static stop(vols)[source]¶
Called after vols have been synced; return
Trueif sync should immediately stop.
- async sync(trans, *, batch=False, parallel=False, transfer_existing=False, volgroups=None, target=None, parent=None, check=None, stop=None)[source]¶
Perform synchronization of subvolumes.
Returns whether the sync was successful and all error handling is delegated to trans.
- Parameters
trans –
Transfer-like object to perform the actual send/receive operationsbatch – if
True, batch together multiple volumes into a single transferparallel – if
True, run independent transfers in paralleltransfer_existing – if
True, consider for transfer volumes that already exist on the destinationvolgroups – override for
volgroups()target – override for
target()parent – override for
parent()check – override for
check()stop – override for
stop()
- Returns
Trueif sync successful,Falseif errors occured
- class btrsync.sync.ProgressTransfer(*, period=1, prog_seq=[], **kwargs)[source]¶
Transfer class providing a mechanism for logging transfer progress.
- Parameters
period – time, in seconds, between progress reporting events
prog_seq – sequence to be cycled through to indicate activity
kwargs – additional keyword arguments to pass to the superclass
Transfer’s constructor
- err(e, *args)¶
Called on encountering an exception e; expected to log the error and return successfully.
- async report(vols, par, src, dst)¶
Called at the start of a transfer of volumes vols with parent par from src to dst.
- async report_done(vols, par, src, dst)¶
Called when the transfer of volumes vols with parent par from src to dst has finished.
- async report_progress(total, prev, seq)[source]¶
Called on every progress reporting event.
- Parameters
total – currrent total bytes transferred
prev – value of total from previous call
seq – sequence to indicate activity
- async transf(vols, par, src, dst)[source]¶
Progress reporting transfer function, as expected by .BtrSync.sync.
- Parameters
vols – the subvolumes to transfer
par – the parent subvolume to use for an incremental transfer
src – the source btrfs root
dst – the destination btrfs root
- Raises
asyncio.CancelledError – if any error has occurred, after logging it with
err()
- async try_await(aw)¶
Try awaiting awaitable aw, converting any exceptions to
asyncio.CancelledError.Exceptions raised by aw will be logged by
err().
- async try_gather(*coroutines)¶
Try running and waiting for all coroutines, canceling all upon error.
Exceptions raised by the tasks will be logged by
err().- Raises
asyncio.CancelledError – if any tasks raise an exception
- class btrsync.sync.Transfer(*, recvpath='.', replicate_dirs=False)[source]¶
Base class implementing a transfer as required by
BtrSync.sync().- Parameters
recvpath – the path that transfers are received into
replicate_dirs – if
Trueadapt recvpath to recreate the sent volumes’ directory structure
- err(e, *args)[source]¶
Called on encountering an exception e; expected to log the error and return successfully.
- async report(vols, par, src, dst)[source]¶
Called at the start of a transfer of volumes vols with parent par from src to dst.
- async report_done(vols, par, src, dst)[source]¶
Called when the transfer of volumes vols with parent par from src to dst has finished.
- async transf(vols, par, src, dst)[source]¶
Minimal quiet transfer function, as expected by
BtrSync.sync().- Parameters
vols – the subvolumes to transfer
par – the parent subvolume to use for an incremental transfer
src – the source btrfs root
dst – the destination btrfs root
- Raises
asyncio.CancelledError – if any error has occured, after logging it with
err()
- async try_await(aw)[source]¶
Try awaiting awaitable aw, converting any exceptions to
asyncio.CancelledError.Exceptions raised by aw will be logged by
err().
- async try_gather(*coroutines)[source]¶
Try running and waiting for all coroutines, canceling all upon error.
Exceptions raised by the tasks will be logged by
err().- Raises
asyncio.CancelledError – if any tasks raise an exception
Modules
Generic interface to a btrfs filesystem. |