Giter VIP home page Giter VIP logo

amlvm-snapshot's Introduction

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"

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

amlvm-snapshot's People

Contributors

andrewbasterfield avatar janekr avatar marxarelli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

amlvm-snapshot's Issues

backup not mounted lvm volume

Hello,

First of all... Greate Job!

But I have small problem... I can't backup not mounted file system.
Problem is in amgtar software... they need to calculate estimate but it try to do on /dev/vg0/some-lvm
Ther is any option to give back to amgtar temporary location in /tmp of mounted LVM ?

Thanks in advanced!

amlvm-snapshot exited with status 1

I am trying to use amlvm-snapshot to do Linux LVM snapshot backup. But keep getting errors in amanda backup report. the relevant content is as follows:

STRANGE DUMP DETAILS:
/-- client-host-name / lev 0 STRANGE
|
? Script 'amlvm-snapshot' command 'PRE-DLE-BACKUP' exited with status 1: see /var/log/amanda/client/daily/sendbackup.20110209144442.debug
sendbackup: info BACKUP=APPLICATION
sendbackup: info APPLICATION=amgtar
sendbackup: info RECOVER_CMD=/usr/bin/gzip -dc |/usr/libexec/amanda/application/amgtar restore [./file-to-restore]+
sendbackup: info COMPRESS_SUFFIX=.gz
sendbackup: info end
? /bin/gtar: ./fe/logs/error_log: file changed as we read it
| /bin/gtar: ./tmp/.font-unix/fs7100: socket ignored
| /bin/gtar: ./tmp/ssh-SFTrOp3063/agent.3063: socket ignored
| /bin/gtar: ./var/run/acpid.socket: socket ignored
| /bin/gtar: ./var/run/audispd_events: socket ignored
| /bin/gtar: ./var/run/pcscd.comm: socket ignored
| /bin/gtar: ./var/run/avahi-daemon/socket: socket ignored
| /bin/gtar: ./var/run/dbus/system_bus_socket: socket ignored
| /bin/gtar: ./var/run/nscd/socket: socket ignored
| Total bytes written: 3300454400 (3.1GiB, 12MiB/s)
sendbackup: size 3223100
sendbackup: end
|
? Script 'amlvm-snapshot' command 'POST-DLE-BACKUP' exited with status 1: see /var/log/amanda/client/daily/sendbackup.20110209144442.debug

/-- client-host-name /boot lev 1 STRANGE
|
? Script 'amlvm-snapshot' command 'PRE-DLE-BACKUP' exited with status 1: see /var/log/amanda/client/daily/sendbackup.20110209144427.debug
sendbackup: info BACKUP=APPLICATION
sendbackup: info APPLICATION=amgtar
sendbackup: info RECOVER_CMD=/usr/bin/gzip -dc |/usr/libexec/amanda/application/amgtar restore [./file-to-restore]+
sendbackup: info COMPRESS_SUFFIX=.gz
sendbackup: info end
| Total bytes written: 10240 (10KiB, 11MiB/s)
sendbackup: size 10
sendbackup: end
|
? Script 'amlvm-snapshot' command 'POST-DLE-BACKUP' exited with status 1: see /var/log/amanda/client/daily/sendbackup.20110209144427.debug

amlvm-snapshot debug file:

Wed Feb 9 16:06:03 2011: Amlvm_snapshot: pid 6003 ruid 5002 euid 5002 version 3.2.1:
start at Wed Feb 9 16:06:03 2011
Wed Feb 9 16:06:03 2011: Amlvm_snapshot: pid 6003 ruid 5002 euid 5002 version 3.2.1:
rename at Wed Feb 9 16:06:03 2011
Wed Feb 9 16:06:03 2011: Amlvm_snapshot: script: Amlvm_snapshot

Wed Feb 9 16:06:03 2011: Amlvm_snapshot: command: post_dle_backup
Wed Feb 9 16:06:03 2011: Amlvm_snapshot: warning: Argument "Failed to execute (statu
s 256) `sudo /usr/sbin/lvdisplay..." isn't numeric in numeric ne (!=) at /usr/lib/per
l5/site_perl/5.8.8/Amanda/Script_App.pm line 101.

I have two perl programs installed on the client side - a original perl from Linux distribution which is x86_64 in /usr/bin; a compiled perl from source which is i386 in /usr/local/bin. I changed the amlvm-snapshot program to just include /usr/bin in PATH but still not successful. I can't see the problem from above debug files.

$ENV{'PATH'} = "/sbin:/usr/sbin:/usr/bin";

Client host is CentOS 5

calculate snapsize

The calculate_snapsize function calculates using the number of free extents, but the --size option for lvcreate seems to want a size in bytes (or m or g)
I think if you do something like

my $extent_size = $parts[12];
my $free_extents  = $parts[15];
...
$self->{snapsize} = $extent_size * $free_extents . "k"
#append k because default is megabytes

Also when I set
property "SNAPSHOT-SIZE" "1000"
in my dumptype it doesnt seem to affect the size of the actual snapshot

I've currently got the value hardcoded in the lvcreate line.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.