Skip to main content

Backup for unix-like systems using rsync.

Project description

rsbackup

CI Status Releases PyPi Wheel Python Versions

A simple rsync-based backup solution for unix systems.

rsbackup is a simple python application that uses rsync to create backups with support for hard links on incremental backups.

Installation

rsbackup requires a working installation of Python 3.10 and the rsync command line tool. rsbackup uses only rsync flags supported on both Linux and BSD versions (i.e. MacOS) of rsync.

Use the following command to install rsbackup:

pip install rsbackup

Usage

rsbackup reads backup configurations from a configuration TOML file. The default filename to read is $HOME/.config/rsbackup.toml but you can specify a different file using the -c cli switch.

The config file contains multiple backup configurations. It looks something like this

[projects]
description = 'All dev projects'
source = '/home/user/projects'
target = '/mnt/backup'
excludes = [
  '__pycache__/',
]

See rsbackup.toml for a documented example.

Each TOML table (i.e. each section header) defines a single backup configuration. The header contains the config's name. This is used as a command line argument to create a backup so pick something that needs no shell escaping.

Each table contains the following keys:

Key Type Optional Description
description string yes contains an optional description.
sources array of string no lists the source directories to create a backup of
target string no contains a target directory which will eventualy contain multiple backups
excludes array of strings yes lists patterns to be excluded from the backup. See the rsync documentation for a description of the pattern format.

You can use

rsbackup list

to get a list of all backup configurations.

To create a backup, run

rsbackup create <name of the config>

This will create a new directory named after the timestamp (in seconds) inside the target to contain the backup.

If you run rsbackup create with the testconfiguration provided in rsbackup.toml you will get the following backup under tmp:

tmp
├── 2022-05-19_15-08-25
│   └── rsbackup
│       ├── config.py
│       ├── config_test.py
│       ├── __init__.py
│       ├── __main__.py
│       ├── rsbackup_test.py
│       ├── rsync.py
│       └── rsync_test.py
└── _latest -> /home/alex/Development/python/backup/tmp/2022-05-19_15-08-25

Of course, the name of the backup directory will depend on the local time you execute the backup. Notice that no __pycache__ directory is contained in the backup as it is excluded.

rsbackup provides the following command line options

Option Default Value Description
-h, --help - display a help message
-c CONFIG_FILE, --config-file CONFIG_FILE $HOME/.config/rsbackup.yaml path of the config file
-m, --dry-run - enable dry run; do not touch any files but output commands instead
--no-link-latest - skip linking unchanged files to latest copy (if exists)

Development

You need Python >= 3.9 to run and thus develop. tomli is used to load TOML files. pytest is used to execute unit and acceptance tests. setuptools is used as a PEP517 build backend.

requirements.txt only contains the minimal set of dependencies to install the application, so it only contains tomli.

License

Copyright 2022, 2023 Alexander Metzner.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rsbackup-0.4.0.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

rsbackup-0.4.0-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file rsbackup-0.4.0.tar.gz.

File metadata

  • Download URL: rsbackup-0.4.0.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for rsbackup-0.4.0.tar.gz
Algorithm Hash digest
SHA256 b2da2b8f0e44f4263f3574c7a053c676859800e0f64c2bfc100afc66d6f67198
MD5 297b02c2ba9ad16ddde665b9b98ff5b0
BLAKE2b-256 17ee7407f18958d1b858c4855173d66971ff75bb3b933ab774d62eaed08b3e87

See more details on using hashes here.

File details

Details for the file rsbackup-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: rsbackup-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 14.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for rsbackup-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1e56f06d1591b294009518b71f72aa16a544fb834a81e1cc1e49f0f9f145f590
MD5 865f3ea46b9edc4d4b7e03490d74fe76
BLAKE2b-256 d5a6786ca3dbcfd8a43e2bb14b5e4ea414cac2730bf3dbab5e6ad8123399e5d8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page