Skip to main content

pibackup

https://img.shields.io/badge/pibackup-pypi-green.svg

Who ever has suffered from corrupted SD-cards, even if new and “high quality” - here’s relief. A scheduled configure-once-and-forget-it backup solution for smart home systems running on linux base, e.g. Raspberry Pi. Covered at date are fhem and iobroker. Feel free to request or contribute extensions.

Building on the well made pieces of software rclone and schedule.

Core functions and Features

  • Create automatic weekly backup of smart home system

  • Take care of backup hygiene, i.e. keeping reasonable number of backups and delete excess

  • Mirroring backups to cloud drive of choice (take what you have, gdrive, dropbox, box, you name it)

  • Install once and forget

  • Running as lightweight background process

  • Tested on Python >3.5

Prerequisites

Python >3.5 with pip

Usage

Follow four easy steps:

  1. Install from PyPi

  2. Run the configuration dialogue

  3. If required, customise the config file

  4. Reboot and relax

The steps are described below in more detail.

1. Install from PyPi

$ sudo pip3 install pibackup

It is encouraged, though not necessary, to install and execute within a virtual environment. For further information on this, read about virtualenv or venv.

In case you install into a virtual environment, please adapt the crontab entry later, as mentioned in section “On adding the cron job”.

2. Run config

Simply invoke from the command line:

$ pibackup-config

This calls a dialogue to set up the system. Essentially, you follow three steps, which are: - generate a config file (enter s) - setup rclone (enter c) - generate a crontab entry to start the process at boot (enter a)

The dialogue looks like this.

***********************************************
***   pibackup - smart home backup system   ***
***********************************************
>>> main

s) Setup config file for pibackup
c) Configure rclone cloud drive
a) Add cron job at reboot to start backup
q) Quit config

s/c/a/q>

Navigate by entering the respective letter. Start with creating the config file:

On setting up the config file

***********************************************
***   pibackup - smart home backup system   ***
***********************************************
>>> main >>> pibackup config file

c) Copy config template to ~/.config/pibackup
q) Quit this page (go back)

c/q>

Entering “c” creates a copy of the config file in the home directory.

Do this and return to the main screen with “q”.

After this, in the main screen, enter “c” to navigate to the rclone setup.

On configuring rclone

This leads straight into the configuration dialogue of rclone itself. As pibackup is a wrapper using rclone, you are now interacting with rclone directly.

The tool is very well documented here. Please have a peek and check the section related to the backup storage you want to use. Typically remote drives such as Google Drive, Dropbox, Box or OneDrive might be in use at your end and considered for storing the backup. While you can use pretty much everything, please find links to popular choices:

As mentioned above: Wherever the documentation asks you to run “rclone config”, this is what you are actually doing in the pibackup dialogue already.

On adding the cron job

Back in the main dialogue, select “a” to amend the crontab, which adds an entry to start the backup process at every reboot.

If you want to double check, do this with:

$ crontab -l

In case you installed in a virtual environment, please adapt the cron table entry to resemble a format like:

@reboot /home/pi/.pibackup-venv/bin/python /home/pi/.pibackup-venv/bin/pibackup &

This calls the virtualenv python interpreter and sets the python path accordingly.

3. Edit config file for customization

The config file is located at ~/.conf/pibackup/config.json.

It looks like this:

{
    "system": {
        "type": "fhem"
    },
    "rclone": {
        "drive_name": "drive:",
        "cloud_path": "/backups/fhem/"
    },
    "schedules": {
        "backup_local": "Wednesday",
        "clean_local": "Thursday",
        "cloud_sync": "Sunday"
    }
}

The three sections describe

  • which system type is in use

  • which parameters to use for rclone

  • Which schedule to follow for the main tool actions

On system type

Currently the system types “fhem” or “iobroker” are supported and can be used as values.

On rclone parameters

The drive name identifies the remote storage location you created in the rclone setup. Please enter the name you used there. Please include the colon at the end, like “drive:” (in the documentation examples it is often “remote:”)

The cloud path specifies the folder on the remote drive. Choose to your liking.

On schedules

Typically you can leave this as is. The parameters are pretty verbose:

  • backup_local schedules the weekday on which the smart phone system backups are run.

  • clean_local schedules the weekday on which the local maintenance on the backup folder is being done.

  • cloud_sync schedules the weekday on which the sync to the cloud drive is performed.

4. Reboot and feel comfortable…

Nice, you did something good for yourself. Congrats and enjoy.

Meta

Philipp Cremer - pc01@arcor.de

Distributed under the MIT license. See LICENSE for more information.

https://github.com/p1ppo/pibackup

Release files for pibackup 0.0.14

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pibackup 0.0.14
File Size Uploaded
pibackup-0.0.14.tar.gz 8.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pibackup 0.0.14
File Interpreter ABI Platform
pibackup-0.0.14-py3-none-any.whl Python 3 none any Details

Total release size: 5.6 MB

Release files / pibackup-0.0.14.tar.gz

Download URL pibackup-0.0.14.tar.gz
Size 8.4 kB
Tags Source
SHA-256 checksum
How to use checksums
707fc2ba4dd83853161b1e243e9c326cbe520465b457464536a78cdf538bd628
BLAKE2b-256 checksum
How to use checksums
9d572fe18c66c3f49e83859695a3b443faa55b385cffc72239467e5ad34a34fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.9.1 pkginfo/1.4.1 requests/2.18.4 setuptools/38.4.1 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.5.3

Release files / pibackup-0.0.14-py3-none-any.whl

Download URL pibackup-0.0.14-py3-none-any.whl
Size 5.6 MB
Tags Python 3
SHA-256 checksum
How to use checksums
e2cff2a87595f446692bc9476a306a1698c1b51b2ae1a09663cbbc99ef8a1d56
BLAKE2b-256 checksum
How to use checksums
dce9366a399205e57fed15d25ae176e5f594a739e5c8cf5d86bba6fcb72870e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.9.1 pkginfo/1.4.1 requests/2.18.4 setuptools/38.4.1 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.5.3

Release history Release notifications | RSS feed

This release

0.0.14 This release

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page