Skip to content

piotr-sikora-v/amlvm-snapshot

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Amanda LVM-snapshot Plugin

This plugin provides support for LVM snapshots in Amanda dumps. It interfaces with Amanda through the Script API.

Install

Sorry, there's no Makefile yet. Simply copy the amlvm-snapshot.pl script into Amanda's application directory.

For example:

install -m 755 -o root -g root amlvm-snapshot /usr/lib/amanda/application/amlvm-snapshot

You may need to edit the location of Amanda's Perl libraries in the script itself, the following line.

use lib '/usr/lib/amanda/perl/';

Configure Amanda

Somewhere in your Amanda config you must define a script-tool that loads the plugin. You can simply include the provided lvm-snapshot.conf file if you like.

cp lvm-snapshot.conf /etc/amanda/DailySet1/lvm-snapshot.conf
echo 'includefile "lvm-snapshot.conf"' >> /etc/amanda/DailySet1/amanda.conf

Once you have the lvm-snapshot script-tool defined, you can include it in a dumptype definition. Note, however, that your dumptype must use an application-tool program: Only application-tool programs can handle the alternate mount point—of the snapshot device—that the script defines.

define dumptype lvm-comp-amgtar {
  comment "LVM snapshot dumped with amgtar"
  global
  program "APPLICATION"
  application "app_amgtar"
  script "lvm-snapshot"
  compress client fast
  index
}

Parallel Backups

To allow Amanda to dump more than one snapshot of the same volume in parallel, you must specify a snapshot size (in PEs) such that multiple snapshots can fit in the available free space—by default, all available free space is used.

For example, if you had a volume with 1000 free extents and required that up to four backups could successfully run in parallel, you would specify the following configuration in lvm-snapshot.conf.

  property "SNAPSHOT-SIZE" "250"

MySQL FLUSH TABLES Feature

This feature exec "FLUSH TABLES WITH READ LOCK" before snapshot. When snapshot is ready plugin will "UNLOCK TABLES" and close mysql connection.

Dependecy is perl DBI with DBD-mysql driver (in debian is libdbd-mysql-perl, in gentoo is dev-perl/DBD-mysql)

To use this feature add few property:

  property "DBMOUNT" "/dev/vg0/var" # device where is mysql datadir
  property "DBUSER" "amanda" # user with RELOAD privileges
  property "DBPASS" "secret" # password
  property "DBHOST" "localhost" # hostname (always needed)
      property "DBPORT" "3306" # port (always needed)

Feature by Piotr ViruS Sikora

Configure Permissions

This plugin requires elevated permissions in order to create and remove LVM devices. There are two ways to provide access: setting setuid on the plugin script itself, or by configuring sudo to allow execution of the LVM programs.

setuid

NOTE: I'm currently having trouble getting this to work right, as Amanda's Perl libraries don't seem to play nice with setuid scripts.

For setuid, simply configure the ownership and mode on amlvm-snapshot. In this example, disk is the group that Amanda runs under.

chown root:disk /usr/libexec/amanda/application/amlvm-snapshot
chmod 4750 /usr/libexec/amanda/application/amlvm-snapshot

This will require that you have a version of Perl installed that was compiled with ENABLE_SUIDPERL.

sudo

For sudo, add the following to the /etc/sudoers file where "amandabackup" is the name of your Amanda user.

amandabackup    ALL=(ALL) NOPASSWD: /sbin/lvcreate, /sbin/lvdisplay, /sbin/lvremove, /sbin/vgdisplay, /bin/readlink, /bin/mount, /bin/umount, /sbin/blkid

The commands listed are those used by amlvm-snapshot to interact with the LVM volumes.

Remember to enable the SUDO property. This is already included in the example lvm-snapshot.conf file.

define script-tool lvm-snapshot {
  # ...
  property "SUDO" "1"
}

Enjoy, Daniel

About

A plugin for Amanda that provides LVM snapshot-ing.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Perl 100.0%