LNBACKUP

Name

lnbackup -- hardlink backup system for hard drives

Synopsis

lnbackup [--backup-name my_backup] [--backup] [--mount] [--umount] [--mirror-only] [--status] [--nagios] [--nagios-all] [--config-dir config_dir] [--log-level log_level] [--log-file log_file]

lnmount

lnumount

DESCRIPTION

This manual page documents briefly the lnbackup command.

lnbackup is a hardlink backup system for hard drives. It creates incremental backups using hardlinks so that each backup seems like a full backup.

lnbackupcan be used to make backup of whole system or selected directories.

lnbackup is usually used to create backups on a separate disk or partition, but it can also operate on o directory, both localy or remotely e.g. over NFS.

Optionally lnbackup can create bootable mirror.

lnmount and lnumount are shortcut wrappers for lnbackup --mount and lnbackup --umount respectively. All arguments given to lnmount are passed to lnbackup.

OPTIONS

These programs follow the usual GNU command line syntax, with long options starting with two dashes (`-'). Description of options is included below.

--backup-name

Give a name of pre-configured backup (defaults to 'localhost').

-l --log-file FILE

Set log file (defaults to /var/log/lnbackup).

-v --log-level LEVEL

Set level of debug information. One of debug, [info], warn, error, fatal. Defaults to info.

-c --config-dir PATH

Set config directory where configuration of individual backups as well as global configuration is stored. Defaults to /etc/lnbackup.d/.

-t --test

Run in test mode (no action is done). Useful together with -v debug when debugging backup configuration. Allows you to see what actions would be done.

-m --no-mirror

Don't create mirror even when mirroring is configured.

--mirror-only

Create only bootable mirror from latest backup.

-s --status

Report status for given backup.

--backup

Run given backup.

--mount

Mount given backup.

--umount

Unmount given backup.

--nagios

Give short status for given backup information suitable for monitoring system Nagios. Also returns exit codes like Nagios plugins.

0 -- ok, 1 -- warning, 2 -- error.

--nagios-all

Same as --nagios except it gives status of all configured backups (in given backup config directory) that do not have the key :dont_check set to true value.

--init-crypto=SIZE

Initialize crypto device (optional size applies to loopback file size). See section ENCRYPTED BACKUPS for more information.

This command creates encrypted loopback device and formats it as ext3 filesystem to ease the process of creating encrypted backup. USE WITH MAXIMAL CARE.

EXAMPLES

lnbackup --backup

Run backup 'localhost'.

lnbackup --backup --backup-name backup2 -v debug -t

Run backup 'backup2', set loglevel to 'debug' (highest), and run in test mode (don't do anything, just pretend and log).

BASIC CONFIGURATION

By default config files are stored in /etc/lnbackup.d/. Configuration consists of individual config files, some of which are global, like file 00global, other define individual backups, like 01localhost.

File 00global is in Debian maintained by debconf and defines basic values such as backup mountpoint, backup disk and backup partition. These values are global for all defined backups, but can be overriden in config files of individual backups.

All configuration files are Ruby hashes. When lnbackup starts it merges all config files into one config hash. Reason for this is to allow some files to be maintained by hand and others by system or let backup config files be added by other packages.

If you redefine some key defined in one file in another file, keep in mind that config files are merged in order given by numerical value of the first two letters of their names.

File 00global file might look like this:

|    {
|        :device        => '/dev/hdc1',
|        :disk          => '/dev/hdc',
|        :mount_point   => '/mnt/backup',
|    } 
This says, that backup device will be /dev/hdc1, this device will be mounted on /mnt/backup. And it is part of device /dev/hdc. Device /dev/hdc will be the device for lilo to write boot sector if some backup is configured to create bootable mirrors.

Backups will be stored under this mountpoint in directory structure of the form /mnt/backup/YYYY/MM/DD/backup_name/ or alternatively /mnt/backup/YYYY/MM/DD/HH/backup_name/.

Default configuration file 01localhost, which defines backup of whole system looks like this:

|   {
|     :localhost => {
|       :dirs => [
|         { :dir => '/',     :fs_type => :single,       # don't backup data below mountpoints
|           :exclude => [ 'tmp/.', 'backup/.' ]
|         },
|         { :dir => '/boot', :fs_type => :single },
|         { :dir => '/usr',  :fs_type => :local  },     # don't backup if mounted over network
|         { :dir => '/var',  :fs_type => :local, 
|           :exclude => ['cache/apt/archives/.*deb', 'spool/squid/.']
|         },
|         { :dir => '/home', :fs_type => :local },
|         { :dir => '/opt',  :fs_type => :local },
|       ],
|       :mirror => true,
|     },
|   }

The key :localhost says, that we define backup named "localhost". It is a good idea to name the file with backup definition with the name of the backup. Number 01 preceding the backup name defines order in which the configuration file is merged into program's configuration as described above.

The key :dirs defines list of directories to be included in the backup and says what rules apply to this directory.

The key :mirror says that we want lnbackup to make bootable mirror from this backup. See section BOOTABLE MIRRORS for details.

Definition of directory to be backuped consists of 3 keys:

When backing up files in directory the most specific :dir entry takes precedence. E.g. if backing up files in directory under /var/lib/ rules for /var take precedence over rules for /.

BOOTABLE MIRRORS

lnbackup can save your day, if you use bootable mirrors. In that case you can simply boot the backup disk in case when master disk fails. We use lnbackup this way on almost all servers we maintain.

Bootable mirrors work in this way:

  1. Normal backup is done the same way as without bootable mirror.

  2. After normal backup is done, last backup is copied into the root of the backup device. Then /etc/fstab on the backup device is generated.

  3. Finally, unless given backup has key :skip_lilo set to true value, lilo is called to make backup disk bootable.

The key :skip_lilo comes in handy when you use boot loader such as grub which doesn't need to be updated each time when location of kernel image, initramdisk, etc. is chanded. With grub it is enough to make the backup disk bootable only once -- when you setup lnbackup for the first time.

ENCRYPTED BACKUPS

lnbackup supports encrypted backups via loop, cryptoloop and cipher (e.g. aes) kernel modules.

Encrypted backup devices cannot be used as bootable mirrors.

Configuration fragment for encrypted backups might look like this (file 00crypto).

|   {
|       :crypto => 'aes256',
|       :password => 'somelongpassphrase',
|   }
This configuration fragment says, that kernel cipher aes256 will be used (must be present in running kernel in the time of backup) and gives the passhprase for the cipher.

USING LABELS

Lnbackup can be configured to locate backup disk using ext3 filesystem labels or UUIDs.

You can use tune2fs to label filesystems. E.g. to label filesystem /dev/sdb1 with label BACKUP run the following command: tune2fs -L BACKUP /dev/sdb1.

Example configuration for using filesystem labels. /etc/lnbackup.d/00global

|      {
|        :device      => '/dev/sd[c-z]*1',
|        :disk        => '/dev/sd[c-z]*',
|        :mount_point => '/mnt/backup',
|        :files_reserved  => '0%',
|        :blocks_reserved => '0%',
|      }
      
/etc/lnbackup.d/01localhost
|      {
|        :localhost => {
|          :dirs => [ { :dir => '/', :fs_type => :single, 
|                       :exclude => [ 'tmp/.', 'backup/.' ] } ]
|          :device_label => 'BACKUP_SW_.*',
|        },
|      }
      

CAUTION: It is not currently possible to use encrypted backup together with labels.

SEE ALSO

Configuration files in /etc/lnbackup.d/.

Czech manual is also available. See lnbackup-manual.cz.txt located in /usr/share/doc/lnbackup-ng/.

AUTHOR

This manual page was written by Martin Povolny (). Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts.