Backup Manager is a comprehensive backup tool providing a host of data backup methods. While too simple to manage a server farm, it is perfectly able to backup a lone server.

This howto is tested on:

  • Debian 10.0 Buster

Settings

Initialize the settings associative array:

declare -A bmSettings

Set the group owning the backup archives and its access permissions:

bmSettings['BM_REPOSITORY_GROUP']='backup'
bmSettings['BM_REPOSITORY_CHMOD']='750'
bmSettings['BM_ARCHIVE_CHMOD']='640'

Enable the incremental archiving method (by default, master archives are created every monday, and incremental archives are created everyday of the following week):

bmSettings['BM_ARCHIVE_METHOD']='tarball-incremental'

Set the archives compression format (among tar, tar.gz, tar.bz2, tar.xz, tar.lzma, dar, zip):

bmSettings['BM_TARBALL_FILETYPE']='tar.bz2'

Disable the default exports methods:

bmSettings['BM_UPLOAD_METHOD']='none'
bmSettings['BM_BURNING_METHOD']='none'

Set the nice level of the archiving process (see “nice” man page for additional info):

bmSettings['BM_ARCHIVE_NICE_LEVEL']='19'

Disable the strict purge of old archives if the archive path contains archives sent by other hosts, otherwise only archives created by the local backup-manager are removed:

bmSettings['BM_ARCHIVE_STRICTPURGE']='false'

Installation

Detect if sudo is available (“command” is used if not):

cmdProxy='command'
command type -f 'sudo' &>'/dev/null' && cmdProxy='sudo'

Environment setup

Install the software:

callChain=("DEBIAN_FRONTEND=noninteractive" "${cmdProxy}")
test "${cmdProxy}"='sudo' && callChain=('sudo' "DEBIAN_FRONTEND=noninteractive")
${callChain[@]} apt install 'backup-manager' 'bzip2' 'zip'

Setup a cron task to backup the host daily:

${cmdProxy} tee '/etc/cron.d/backup-manager' \
  <<< "#
# Daily cron jobs for backup-manager.
# See /etc/backup-manager.conf
#
# Every day at 1 o'clock.
0 1 * * *   root    test -x /usr/sbin/backup-manager && /usr/sbin/backup-manager"

Reload cron daemon configuration:

${cmdProxy} systemctl 'restart' 'cron'

Apply the settings:

declare -a sedOptions
sedOptions=()
for settingName in ${!bmSettings[@]}; do
  sedOptions+=( '-e' "s|[#]*\(.*${settingName}=\).*$|\1\"${bmSettings["${settingName}"]}\"|" )
done
${cmdProxy} sed -i "${sedOptions[@]}" '/etc/backup-manager.conf'

Disable the BM_TARBALL_DIRECTORIES single line option and replace it by the BM_TARBALL_TARGETS array (for better readability of the configuration file):

if ${cmdProxy} grep -q '^export BM_TARBALL_DIRECTORIES=' '/etc/backup-manager.conf'; then
  # Store existing BM_TARBALL_DIRECTORIES as targets.
  IFS=' ' read -r -a 'targets' \
    <<< "$(${cmdProxy} grep '^export BM_TARBALL_DIRECTORIES=' '/etc/backup-manager.conf' \
      | sed -e 's/^.*DIRECTORIES="\(.*\)".*$/\1/')"

  # Build the new configuration using BM_TARBALL_TARGETS setting.
  confContent=''
  counter=0
  for target in "${targets[@]}"; do
    confContent="${confContent}\\
BM_TARBALL_TARGETS[${counter}]=\"${target}\""
    (( counter++ ))
  done

  # Update the configuration file.
  ${cmdProxy} sed -i \
    -e 's/^\(export BM_TARBALL_DIRECTORIES.*\)$/# \1/' \
    -e 's/^# \(declare.*BM_TARBALL_TARGETS.*\)$/\1/' \
    -e 's/^# \(export.*BM_TARBALL_TARGETS.*\)$/\1/' \
    -e "/^export BM_TARBALL_TARGETS/i\
${confContent}" \
  '/etc/backup-manager.conf'
fi

Next steps

Backup targets management

This howto recommends:

Setup the backup of commonly used paths:

${cmdProxy} bu-tools --add='/etc' --add='/home' --add='/root' --add='/var/backups'
  • /etc: configuration files
  • /home: user accounts files
  • /root: root account files
  • /var/backups: list of installed packages

Storage of remote archives

If the local host has for role to store a copy of a remote system backup archives (as described by Export Backup Manager archives via SFTP), this howto recommends:

Create a user for the remote host to connect to:

${cmdProxy} adduser --ingroup 'sftp-only' --ingroup 'backup' 'bmngr'

Allow group ‘backup’ users to change ‘/var/archives’ contents:

declare -A bmSettings
bmSettings['BM_REPOSITORY_CHMOD']='770'
bmSettings['BM_ARCHIVE_CHMOD']='660'

Apply the settings:

declare -a sedOptions
sedOptions=()
for settingName in ${!bmSettings[@]}; do
  sedOptions+=( '-e' "s|[#]*\(.*${settingName}=\).*$|\1\"${bmSettings["${settingName}"]}\"|" )
done
${cmdProxy} sed -i "${sedOptions[@]}" '/etc/backup-manager.conf'

Thanks

Categories: Backups

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.