Tags


My new backup system

First written on February 8, 2020
Last updated on October 31, 2021

Introduction

Last year I wrote a post about my backup system.

In the meantime some things have changed:

and other did not:

Steps

  1. install Rsync, Cryptsetup, and GNU Bash.

  2. follow the steps related to the encrypted backups in this previous post.

The new encrypted backup script

#!/usr/bin/env bash
#
# backup_enc.sh
#
# Copyright (C)  2019-2020  Franco Masotti <franco.masotti@live.com>.
# Permission is granted to copy, distribute and/or modify this document
# under the terms of the GNU Free Documentation License, Version 1.3
# or any later version published by the Free Software Foundation;
# with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
# A copy of the license is included in the section entitled "GNU
# Free Documentation License".

#
# This backup is intended to be run manually.
#

set -euo pipefail

CONFIG="${1}"

. "${CONFIG}"

[ ${UID} -eq 0 ]
cryptsetup open "/dev/disk/by-uuid/"${UUID}"" "${MAPPER_NAME}"
mount /dev/mapper/"${MAPPER_NAME}" "${DST}"
set +e
rsync --verbose --archive --acls --xattrs --hard-links --delete "${SRC}"/* "${DST}"
set -e
sync
umount "${DST}"
cryptsetup close "${MAPPER_NAME}"

Configuration file

Create a configuration file for every backup.

You must put the correct UUIDs of the partition in the configuration file. Copy the appropriate one from:

$ lsblk -o name,uuid

This is an example for the root mountpoint of host one:

#
# backup_enc.hostone_root.conf
#
# Copyright (C)  2019-2020  Franco Masotti <franco.masotti@live.com>.
# Permission is granted to copy, distribute and/or modify this document
# under the terms of the GNU Free Documentation License, Version 1.3
# or any later version published by the Free Software Foundation;
# with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
# A copy of the license is included in the section entitled "GNU
# Free Documentation License".

UUID='<put the uuid here>'
MAPPER_NAME='hostone_root_enc'
SRC='/mnt/backups/hostone_root'
DST='/mnt/backups_enc/hostone_root'

First backups

Once you have everything in place you may start the backup as root:

# ./backup_enc.sh ./backup_enc.hostone_root.conf

~

Enjoy!


Post a new comment