This library allows blocksync script to be used as Python package, and supports more convenient and various functions than blocksync script.
- Python 3.8 or later
- Synchronize the destination (remote or local) files using an incremental algorithm.
- Supports all synchronization directions. (local-local, local-remote, remote-local)
- Support for callbacks that can run before(run once or per workers), after(run once or per workers), and during synchronization of files
- Support for synchronization suspend/resume, cancel.
- Most methods support method chaining.
- You can see the overall progress in a multi-threaded environment.
- You can proceed synchronization in the background.
- You can specify the number of workers (number of threads) to perform synchronization.
pip install blocksync
- local - local
from blocksync import local_to_local
manager, status = local_to_local("src.txt", "dest.txt", workers=4)
manager.wait_sync()
print(status)
# Output
[Worker 1]: Start sync(src.txt -> dest.txt) 1 blocks
[Worker 2]: Start sync(src.txt -> dest.txt) 1 blocks
[Worker 3]: Start sync(src.txt -> dest.txt) 1 blocks
[Worker 4]: Start sync(src.txt -> dest.txt) 1 blocks
{'workers': 4, 'chunk_size': 250, 'block_size': 250, 'src_size': 1000, 'dest_size': 1000, 'blocks': {'same': 4, 'diff': 0, 'done': 4}}
- local - remote
When sync from(or to) remote, you can check the SSH connection options in paramiko docs.
from blocksync import local_to_remote
manager, status = local_to_remote(
"src.txt",
"dest.txt",
workers=4,
hostname="hostname",
username="username",
password="password",
key_filename="key_filepath",
)
manager.wait_sync()
- Provide CLI
- Write docs and build a docs website
MIT License (For more information about this license, please see this)