Skip to content

restic b2

Mihir Lad edited this page Jun 7, 2020 · 3 revisions

The Feature

This feature installs backup scripts and set ups systemd services which automatically backup your home directory, etc, and the root directory every day to a B2 Cloud Storage bucket using restic. Part of the feature includes a clean script and service which cleans up the backup weekly. All of the backup executables and secrets are stored in the /root directory for security.

Note: this feature requires a B2 Cloud Storage bucket and a B2 account. Storage is priced by usage.

Configuration

In the conf/restic-b2 folder, the constants.sh.sample file can be copied to conf/restic-b2/constants.sh to include your configuration for restic.

Here's a sample configuration:

#!/usr/bin/bash

# Edit this file and rename to constants.sh

if [[ -z "$CONSTANTS_SH_" ]]; then
    CONSTANTS_SH_=1

    NOTIFY_USER='johndoe255'
    O_OPTIONS="-o b2.connections=5"

    export B2_BUCKET='johnsbucket'
    export B2_KEY_NAME='johnskey'
    # Same as B2_KEY_ID
    export B2_ACCOUNT_ID='wdawdlj2e1312312kl'
    export B2_ACCOUNT_KEY='adawdawdjlawjdlawjdj2l4j'
    B2_DIR=""
    export B2_PATH="b2:${B2_BUCKET}/${B2_DIR}"

    export RESTIC_REPOSITORY="b2:${B2_BUCKET}"
    export RESTIC_PASSWORD='johnsstrongpassword'
    export RESTIC_CACHE_DIR="/root/.cache"

    export DISPLAY=:0
fi

NOTIFY_USER is the username on your computer to send notifications to about backup progress.

B2_KEY_NAME, B2_BUCKET, B2_ACCOUNT_ID, and B2_ACCOUNT_KEY can be obtained from your account page on backblaze.com

B2_DIR is the path to the directory in the bucket to store the backup repo.

DISPLAY is the default X11 display to use for sending notifications.

If any of these values are not set in the configuration, you will be prompted for them during the feature installation.

constants.sh

In addition, the conf/restic-b2/excludes.txt and conf/restic-b2/includes.txt can be edited to add/remove any paths to include/ignore when backing up.

excludes.txt

includes.txt

Online Resources

https://help.backblaze.com/hc/en-us/articles/115002880514-How-to-configure-Backblaze-B2-with-Restic-on-Linux

Clone this wiki locally