rsync

This plugin uses rsync to sync directories local and remote.

Dependencies

  • rsync
  • ssh: This is needed for remote syncs.

Configuration

A list of required configuration keys:

  • source: A directory that should be synced.
  • destination: The directory the backup should be synced to.

Its also needed to define a mode. Here is a list:

  • once: Syncs one to one. It also deleted files on destination that are not there anymore.
  • week: Keeps one week. It stores the files in a numbered day directory and uses hardlinks to link to the files that are not changed from the day before.
  • month: Keeps one month. it stores the files for one month in a day numbered directory and works with hardlinks just like the week mode.

It supports rsync exclude and include patterns as list.

Here’s an example:

logs:
  dir: /var/log/dothebackup
  keep: 10
backup:
  my_documents:
    type: rsync
    enabled: yes
    mode: month
    source: /home/myuser/documents
    destination: /media/backup/documents
    exclude:
      - foo
      - bar
    include:
      - importantdir

This would save the source to /media/backup/documents/27 for example and rotate for one month with day numbers.

It supports ssh for transfering data to remote hosts. For example:

logs:
  dir: /var/log/dothebackup
  keep: 10
backup:
  my_documents:
    type: rsync
    enabled: yes
    mode: once
    source: /home/myuser/documents
    destination: ssh://foo@remotehost:/media/backup/documents

Be sure that you are allowed to connect and ssh-keys are exchanged.

API

Rsync.

dothebackup.plugs.rsync.main(config)[source]

Command builder.

Parameters:config (Dict[str, Union[str, List[str], bool]]) – config snippet for this plugin
Return type:List[List[str]]
Returns:Commands to create the backup
dothebackup.plugs.rsync.normalize_path(path)[source]

Returns a normalized path.

Rsync needs a normalized path and special handing if its a ssh path.

Parameters:path (str) – Path to normalize
Return type:str
Returns:Normalized path