Simple and safe python wrapper for calling system rsync
Slowing down. Last release over 3 years ago, little activity since. Fine for existing code; think twice for a new project.
$
pip install sysrsyncsysrsync
Simple and safe native rsync wrapper for Python 3
Requirements
- rsync
- python 3.6+
development:
- poetry (be sure to have both poetry and pip upgraded to the latest version)
Installation
pip install sysrsync
Basic rules
- Syncs source contents by default, so it adds a trailing slash to the end of source, unless
sync_source_contents=Falseis specified - Removes trailing slash from destination
- Extra arguments are put right after
rsync - Breaks if
source_sshanddestination_sshare both set
Usage
- Basic file sync
import sysrsync
sysrsync.run(source='/home/user/foo.txt',
destination='/home/server/bar')
# runs 'rsync /home/users/foo.txt /home/server/files'
- sync whole folder
import sysrsync
sysrsync.run(source='/home/user/files',
destination='/home/server/',
sync_source_contents=False)
# runs 'rsync /home/user/files /home/server'
- sync folder contents
import sysrsync
sysrsync.run(source='/home/user/files',
destination='/home/server/',
sync_source_contents=True)
# runs 'rsync /home/user/files/ /home/server'
- ssh with options
import sysrsync
sysrsync.run(source='/home/user/files',
destination='/home/server/files',
destination_ssh='myserver',
options=['-a'])
# runs 'rsync -a /home/users/files/ myserver:/home/server/files'
- exclusions
import sysrsync
sysrsync.run(source='/home/user/files',
destination='/home/server/files',
destination_ssh='myserver',
options=['-a'],
exclusions=['file_to_exclude', 'unwanted_file'])
# runs 'rsync -a /home/user/files/ myserver:/home/server/files --exclude file_to_exclude --exclude unwanted_file'