easily backup directories to remote and local devices and sync data between devices.
bkup is written for Python 3)
You should have your SSH keys on all remote machines you will be accessing.
For reference, you can do this like so:
$ ssh-copy-id <user>@<host> # Example: $ ssh-copy-id firstname.lastname@example.org
pip install bkup
Setup your backup configuration in
It takes the format:
task_name: dirs: - '~/some/local/dir' - '~/other/local/dir' targets: - 'me@somehost:/path/to/backup/to' - '/mnt/local/path/to/backup/to'
Note that this uses
rsync underneath, so just be aware of how it handles source paths with and without trailing slashes differently (here is a quick explanation).
For example, in the config above, the source directory
~/some/local/dir is synced onto
If the source directory had ended with a trailing slash, i.e.
~/some/local/dir/ is synced onto
bkup has two modes:
- push: backup files from one machine to many machines (default)
- sync: syncs files of multiple machines to each other
To use the sync mode, just add
sync: true to a task's configuration.
The sync mode should not have any
dirs specified because it treats all directories as remote.
The sync mode requires that all listed hosts have SSH key access to each other (otherwise
rsync will throw permission errors). As a reminder, this is easily accomplished by generating a key with
ssh-keygen (if you do not already have one) and then copying the key to another host with
Deleting files and the safety option
For push mode, the optional
never_delete property is a setting which,
if set to
true, will never destructively sync, even if the user specifies it
This is useful, for instance, when you want to have an archiving task which syncs local folders to the remote host but does not propagate deletions. That way, you can delete files in the local folder without them being deleted in the remote folder.
Sync mode never deletes anything. So if you rename a file, you will need to manually delete the old file from other devices. If you delete a file, you will need to manually delete it from other devices.
To use, simply do:
bkup <task name> [--delete]
--delete flag will destructively sync (unless
never_delete is set to
true for the task or it is a sync task).