btrsync
Replicate btrfs subvolumes, handling Copy-on-Write (COW) relationships and incremental transfers automatically.
Documentation is on Read the Docs. Code repository and issue tracker are on GitHub.
Background
btrfs is a modern Linux Copy-on-Write (COW) filesystem supporting powerful features such as snapshotting and incremental serialization. This makes it easy to efficiently replicate related snapshots from one filesystem to another by transferring only the differences between them.
What is not easy, however, is manually identifying and tracking these relationships in order to fully leverage the features of btrfs. Built-in tools provide the necessary mechanisms, but the heavy lifting is left to the user.
This is where btrsync comes in.
True to its name, btrsync is "rsync, but for btrfs", reducing the complex task of comparing and replicating snapshots down to a one-liner:
btrsync SOURCE DESTINATION
Features
- Handles subvolume discovery and incremental transfers automatically
- Supports local and remote machines (through SSH)
- Intuitive CLI inspired by familiar tools like rsync and scp
Usage
Command-line
Run the main command-line interface with
python -m btrsync.cli [OPTIONS] SOURCE [SOURCE ...] DESTINATION
(replace python with python3 if your system's python defaults to Python 2)
Alternatively, you can directly run
btrsync [OPTIONS] SOURCE [SOURCE ...] DESTINATION
SOURCE arguments are interpreted as follows:
- Arguments ending in
/denote directories and match all subvolumes contained therein - Arguments containing shell wildcards match as expected
- Non-directory arguments with no wildcards match subvolumes verbatim
DESTINATION must reside on a btrfs filesystem.
Additionally, both SOURCE and DESTINATION arguments may:
- be rsync-like SSH locations (i.e., in
user@host:pathform) - be full URLs, with
file://andssh://as accepted schemas
The location syntax is similar on purpose to that of rsync and scp, and principle of least surprise applies.
Examples
A minimal example:
btrsync /snapshots/ /mnt/drive/backup
will transfer all read-only subvolumes below /snapshots/ to /mnt/drive/backup after asking confirmation.
A more involved case, fetching specific subvolumes from a remote machine:
btrsync -svp 'user@host:snaps/dev*' devsnaps/
will transfer subvolumes that match snaps/dev* from the SSH remote host host, logged in as user, to the local directory devsnaps/ after asking confirmation; in addition:
-sexecutebtrfscommands usingsudo-vprint verbose information during transfer-pperiodically report progress
Non-interactive invocation, useful e.g., in scripts:
btrsync -yq --incremental-only /snapshots/ ssh://user@backup.example.com:1234/snaps/
will transfer subvolumes under local directory /snapshots/ to the SSH host backup.example.com, connected as user to port 1234, saving them under the remote path /snaps/; in addition:
-yproceed without asking for confirmation-qdo not print output, except for errors--incremental-onlyskip any transfers that cannot be done incrementally
The help option provides further details:
btrsync --help
API
See the API Reference section of the documentation.
Metadata
Release files for btrsync 0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| btrsync-0.3.tar.gz | 46.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| btrsync-0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 89.4 kB
Release files / btrsync-0.3.tar.gz
| Download URL | btrsync-0.3.tar.gz |
|---|---|
| Size | 46.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cbd0f7a874784c155dd15f7f79c22e76a92830ea71f0b5f228e8c4f1b7d7b148
|
|
BLAKE2b-256 checksum How to use checksums |
10887e77ddc74702bd74642b579f82dc88932a8b3daa218bd896ab2ea58699ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Release files / btrsync-0.3-py3-none-any.whl
| Download URL | btrsync-0.3-py3-none-any.whl |
|---|---|
| Size | 42.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d25975374176d2d6a1c6f8e0aa0d2f8aac20afa2f20eab8ee6f6126bc9b2ec1b
|
|
BLAKE2b-256 checksum How to use checksums |
ebf2041427b9306393f099b7a9799bff1fd3b9dc0ae0dd46835022483cedb71b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|