## Sync


## sync.mirror()


Replicate `src` onto `dst` (a local path or `"host:path"`) and verify it by sha256.


Usage

``` python
sync.mirror(
    src,
    dst,
    *,
    delete_source=False,
)
```


Runs `rsync -a`, sweeps AppleDouble `._*` files after every hop, then diffs a sorted sha256 manifest of both trees; a mismatch triggers up to `MAX_REPAIR_ROUNDS` checksum re-syncs before raising [SyncVerificationError](sync.md#athome.sync.SyncVerificationError). Source contents are removed only when `delete_source` is set and the tree verifies clean.


#### Parameters


`src: Path`  
The local directory to replicate.

`dst: str`  
The destination, either a local path or an `rsync`/`ssh` `"host:path"` spec.

`delete_source: bool = ``False`  
Remove the source contents once, and only once, the mirror verifies.


#### Returns


`A: `<a href="sync.html#athome.sync.SyncReport" class="gdls-link gdls-code"><code>SyncReport</code></a>  
class:[SyncReport](sync.md#athome.sync.SyncReport) describing the verified transfer.


#### Raises


<a href="sync.html#athome.sync.SyncVerificationError" class="gdls-link gdls-code"><code>SyncVerificationError</code></a>  
A required tool is missing, or the tree stays unverified.


## sync.SyncReport


The outcome of a verified [mirror()](sync.md#athome.sync.mirror): file/byte counts and swept AppleDoubles.


Usage

``` python
sync.SyncReport(files, bytes, verified, swept_appledoubles)
```


#### Parameter Attributes


`files: int`  

`bytes: int`  

`verified: bool`  

`swept_appledoubles: int`  


## sync.SyncVerificationError


A mirror could not be verified clean; carries the unverified file list in `mismatches`.


Usage

``` python
sync.SyncVerificationError(message, *, mismatches=())
```
