Skip to main content

Scheduled cloud backup for Raspberry Pi running smart home systems like fhem or iobroker

Project description

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

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

pibackup-0.0.14.tar.gz (8.4 kB view hashes)

Uploaded Source

Built Distribution

pibackup-0.0.14-py3-none-any.whl (5.6 MB view hashes)

Uploaded Python 3

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