Tested on OpenBSD 6.3 with borgbackup-1.1.4p0

Archive with borg(1)

Borg is a deduplicating archiver with compression and encryption.

Install

# pkg_add borgbackup
...
borgbackup-1.1.4p0: ok
#

Initialize

$ borg init -e repokey -v ~/archives
Initializing repository at "archives"
Enter new passphrase:
Enter same passphrase again:
Do you want your passphrase to be displayed for verification? [yN]:
Remember your passphrase. Your data will be inaccessible without it.
Key in "<Repository /home/romanzolotarev/archives>" created.
Keep this key safe. Your data will be inaccessible without it.
Synchronizing chunks cache...
Archives: 0, w/ cached Idx: 0, w/ outdated Idx: 0, w/o cached Idx: 0.
Done.
$

Back up

$ borg create ~/archives::src-20180626-1304 src
Enter passphrase for key /home/romanzolotarev/archives:
$

Restore

$ cd /tmp
$ borg extract -v --list ~/archives::src-20180626-1304 src/www/borg.md
Enter passphrase for key /home/romanzolotarev/archives:
src/www/borg.md
$ sha256 /tmp/src/www/borg.md ~/src/www/borg.md
SHA256 (/tmp/src/www/borg.md) = 66d23...
SHA256 (/home/romanzolotarev/src/www/borg.md) = 66d23...
$

Set up a remote storage

To keep archives off-site set up your own server or sign up for Rsync.net ($10/year for 40 GB or $0.24/year/GB).

Automate

Create ~/bin/borgbackup script like this:

#!/bin/sh
export BORG_REPO='USERNAME@SERVER.rsync.net:REPO'
export BORG_RSH="ssh -i $HOME/.ssh/PUBLIC_KEY"
export BORG_REMOTE_PATH='/usr/local/bin/borg1/borg1'
export BORG_PASSPHRASE='PASSPHRASE'

archive=$(date +%Y%m%d-%H%M)
borg create -C lzma,9 -p \
    --exclude '*/.cache/*' \
    --exclude '*/Downloads/*' \
    "::$archive" "$HOME"

borg prune -v --list --stats \
    --keep-hourly 48 \
    --keep-daily 60 \
    --keep-monthly 12 \
    --keep-yearly 10 \
    '::'
$ chmod 0700 ~/bin/borgbackup
$ ~/bin/borgbackup
...
------------------------------------------------------------------------------
Keeping archive: 20180726-1352                        Thu, 2018-07-26 13:05:15
...
Keeping archive: 20180331-1505                        Sat, 2018-03-31 12:05:37
------------------------------------------------------------------------------
                       Original size      Compressed size    Deduplicated size
Deleted data:                    0 B                  0 B                  0 B
All archives:               66.93 GB             66.65 GB              7.38 GB

                       Unique chunks         Total chunks
Chunk index:                   34152               185692
------------------------------------------------------------------------------
Remote: Starting repository check
Remote: Starting repository index check
Remote: Completed repository check, no problems found.
Starting archive consistency check...
Analyzing archive 20180331-1505 (1/10)
...
Analyzing archive 20180726-1305 (10/10)
Archive consistency check complete, no problems found.
$

Use crontab(1) to run ~/bin/borgbackup by schedule.


© 2008–2019 Roman Zolotarev  User Agreement  Privacy Policy