avibrazil / autorsync

Command to automate execution of various rsyncs based on profiles defined on a YAML configuration file
GNU General Public License v3.0
0 stars 0 forks source link

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).

Check PyPi and GitHub for autorsync.

Usage

Organize Profiles in ~/autorsync.yaml

Here is an example with some defaults and a few profiles:

DEFAULTS:
    source_part1: '{{home}}/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
    extra_part1: --rsh "ssh -i ~/.ssh/id_operator" --no-atimes

profiles:
    - name: books
      source_part2: Books/
      target_part2: '{{hostname}}.books/files'
      background: True
      extra: --copy-links

    - name: nextcloud.data
      source: /var/lib/nextcloud/data
      target_part2: '{{hostname}}.nextcloud_files'
      extra_part2: --copy-links --itemize-changes

Notes about this configuration

Se my real /root/autorsync.yaml file that is used everyday to run my incremental offsite backup via cron.

By the way, this is my root user crontab:

# Several backups everyday 4:15 AM
15 4 * * * $HOME/.local/bin/autorsync

As simple as that.

Example usage