simple_backup

A simple backup script

Description

simple_backup is a Python script that allows you to backup your files. Parameters like input files/directories, output directory etc. can be specified in a configuration file, or on the command line. Run:

simple_backup -h

to print all possible command line options.

Dependencies

simple_backup requires Python 3.10 or later. The script uses rsync to actually run the backup, so you will have to install it on your system. For example on Arch Linux:

sudo pacman -Syu rsync

Optional dependencies are systemd-python to enable using systemd journal for logging, dbus-python for desktop notifications, and paramiko (version 3.2 or later) for remote backup.

Installation

For Arch Linux and Arch-based distros, two packages are available in the AUR (aur.archlinux.org):

  • simple_backup for the release version
  • simple_backup-git for the git version

Install one with your AUR helper, e.g. aur sync simple_backup with aurutils.

Other distributions

First clone the repository:

git clone https://git.shouldnt.work/fuxino/simple_backup.git

Then build the package (this requires the Python build module, e.g. the python-build package on Arch Linux):

cd simple_backup
python -m build --wheel

Many distributions don't allow installing packages with pip into the system Python ("externally-managed-environment" error). In that case, install the wheel in a virtual environment, for example with pipx:

pipx install dist/*.whl

Optional dependencies can be installed as extras, for example pipx install 'dist/simple_backup-<version>-py3-none-any.whl[REMOTE]' (available extras: JOURNAL, NOTIFICATIONS, REMOTE).

Running as root

To back up files that your user can't read, run simple_backup with sudo or doas. In that case the user who ran the command is detected automatically, so that '~' (in the inputs and in the default configuration file path) refers to that user's home directory, not root's. When running as root in other ways (e.g. from a systemd service), specify the user with the --user (or -u) argument.

Progress

When run in a terminal, simple_backup shows a progress bar with the percentage of files copied and an estimated time to completion. Disable it with --no-progress.

Old backups

The number of old backups to keep can be set with the --keep (or -k) argument (or in the configuration file). By default, old backups are only removed if rsync completes successfully, so that they are not deleted when the new backup may be incomplete. The only rsync error that is ignored is return code 24 (source files vanished during the transfer), which is common when backing up a live system. To free space on the destination first, use --remove-before-backup: old backups are then removed before rsync starts, even if the new backup fails.

Last backup

After each successful backup, simple_backup saves its time and directory to ~/.local/state/simple_backup/last_backup (or $XDG_STATE_HOME/simple_backup/last_backup). It also saves the number of files, so that the next run can show progress and an estimated time while rsync is still looking for files. When run with sudo or doas, the file goes to the home directory of the user who ran the command. To see when the last backup was made (e.g. Last backup: 2026-10-25 14:03 (2 days ago)), run:

simple_backup --last-backup

The first line of the file is the completion time in ISO 8601 format (e.g. 2026-10-25T14:03:12+02:00), the second the backup directory, and the third (if known) the number of files. Scripts (e.g. a status bar indicator) can easily read the first line to remind you when a backup is overdue.

Remote backup

Warning

This feature is experimental

It's possible to use a remote server as destination for the backup. Just use the --ssh-user and --ssh-host arguments (or set them in the configuration file). Both are required: if only one of them is set, simple_backup exits with an error. For this to work, rsync must be installed on the server too. The host can be an alias from ~/.ssh/config: its HostName, Port and IdentityFile are used (ProxyJump and ProxyCommand are not supported).

The output directory is a path on the server. A leading '' and relative paths refer to the user's home directory on the server. On the command line, quote '' so that your local shell doesn't expand it:

simple_backup --ssh-host server --ssh-user user -o '~/backups'

Server authentication

The best way to handle the authentication is to have an ssh agent running on your system, otherwise if a passphrase is necessary to unlock the ssh key, it will be necessary to enter it more than once. If needed, it's possible to specify the ssh key location with the --keyfile argument or in the configuration file.

To be able to connect to the user's ssh agent when running simple_backup with sudo, make sure to preserve the SSH_AUTH_SOCK environment variable. For example:

sudo --preserve-env=SSH_AUTH_SOCK -s simple_backup [options]

or by editing the sudoers file. If SSH key authentication is not available, password authentication will be used instead. In that case, if sshpass is installed, it is used to pass the password to rsync, so that you only have to enter it once; otherwise you will be asked for it more than once. sshpass has some security risks (see sshpass(1)), so use SSH key authentication if possible. Check the man page for more details.

S
Description
No description provided
Readme GPL-3.0
1.1 MiB
Languages
Python 98.9%
Shell 1.1%