Automate execution of various rsync commands based on profiles defined on a YAML configuration file
Project description
Auto rsync
Command to automate execution of various rsync commands based on profiles defined on a YAML configuration file.
Installation
pip3 install auto-remote-sync --user
(Sorry for the long package name, ideally this would be simply autorsync, but name autosync
was already taken and PyPi would not allow similar names)
Usage
Organize Profiles in ~/autorsync.yaml
Here is an example with some defaults and a few profiles:
DEFAULTS:
source_part1: /media/Media
target_part1: user@remote.host.com:/media/backup/filesets
delete: True
backup: True
backup_dir: ../deleted/{{time.strftime('%Y.%m.%d-%H.%M.%S')}}/
background: False
profiles:
- name: books
source_part2: Books/
target_part2: '{{hostname}}.books/files'
background: True
- name: nextcloud.data
source: /var/lib/nextcloud/data
target_part2: '{{hostname}}.nextcloud_files'
Notes about this configuration
- All profiles inherit parameters from
DEFAULTS
. If parameter isn’t set in the profile, the value defined inDEFAULTS
will be used. - For each profile, the Source is defined by
source
parameter, or, if not defined, bysource_part1/source_part2
- Target follows same logic:
target
ortarget_part1/target_part2
delete
makes rsync delete files in target that are absent in sourcebackup
andbackup_dir
makes rsync save backups on target of deleted or modified files. Value onbackup_dir
is a path relative to target folder- You can use Jinja logic in path parts, surrounded by
{{}}
. Currently these are the available variables:time
, a Pythondatetime.datetime
object which includes local timezonehostname
, such as “rocket”username
, as “joanbaez”home
, as “/home/joanbaez”userid
, as “504”gecos
, as “Joan Baez”
Execution
- Show all profiles:
autorsync -l
- Run rsync for all profiles:
autorsync
- Run rsync only for profile
books
autorsync -p books
- Simulate rsync only for profile
books
(force rsync’s--dry-run
)
autorsync -n -p books
or
autorsync --dry-run -p books
- Run rsync for 2 profiles from a non-default configuration file:
autorsync -c /etc/autorsync.yaml -p "books, music, photos"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
auto_remote_sync-1.0.1.tar.gz
(5.4 kB
view hashes)
Built Distribution
Close
Hashes for auto_remote_sync-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27582ab12a5f96a7fcf723215094401eabf80060d877c560b64245234f1ac4d3 |
|
MD5 | d58f58e180dcee2a3e5c879cfc3a1e58 |
|
BLAKE2b-256 | c02e9f6b6b23091b8ac5e821d9a83a90b20ce8503334eb85526bfcf884de07a9 |