Amanda-Users

Backup after LVM snapshot

2005-06-30 20:54:35
Subject: Backup after LVM snapshot
From: Maurice Poisson Adriasola <mpoisson AT aconcagua DOT cl>
To: amanda-users AT amanda DOT org
Date: Thu, 30 Jun 2005 20:35:53 -0400
I intend to backup a host without stopping its services. To achieve it
I've put Debian Sarge's "amdump" in a wrapping bash script that does the
following:

1) Open an ssh connection, as root, to the host to be backed up and run
on it a script that creates and mounts a snapshot of the /var
filesystem.

2) Run Sarge's amdump script

3) Open an ssh connection, as root, to the already backed up host and
run a script that unmounts the snapshot and removes it.

For the time being the only host that has to be backed up is the amanda
server itself. Backups seem to be done right, but once every two runs
the hosts hangs and needs to be rebooted just after doing the backup.

amcheck is done a couple of hours before amdump. It is also preceded by
snapshot creation and followed by snapshot removal and it never fails,
Thus I believe I must have overlooked something in amanda's
configuration.

Can somebody give me a hint so as to make this work?

TIA. Maurice Poisson

Linux Kernel 2.6.8 SMP (Debian Sarge), LVM2, dm-snapshot module loaded
at startup.

/etc/amanda/DailySet1/amanda.conf is as follows

----
org "DailySet1"
mailto "root"
dumpuser "backup"
inparallel 4
netusage  600

dumpcycle 1 week
runspercycle 6
tapecycle 13

bumpsize 20 MB
bumpdays     1
bumpmult     4

tapedev "/dev/nst0"

tapetype Python-DDS2
labelstr "^DailySet1[0-9][0-9]*$"

diskdir "/usr/dumps"
disksize 290 MB


infofile "/var/lib/amanda/DailySet1/curinfo"
logfile  "/var/log/amanda/DailySet1/log"

indexdir "/var/lib/amanda/DailySet1/index"


define tapetype Python-DDS2 {
    comment "ARCHIVE Python with DDS2 tape"
    length 3860 mbytes
    filemark 16 kbytes
    speed 707 kps
}

define dumptype comp-user-tar {
    program "GNUTAR"
    comment "partitions dumped with tar"
    options compress-fast, index, exclude-list
"/etc/amanda/exclude.gtar"
    priority medium
}
----

/etc/amanda/DailySet1/disklist is as follows:

----
venus etc  /etc comp-user-tar 1

venus boot /boot comp-user-tar 1

venus var  /mnt/var {
  comp-user-tar
  include "./lib/postgres" "./lib/cyrus/db" "./lib/cyrus/deliver.db"
"./lib/cyrus/mailboxes.db" "./lib/cyrus/quota"
"./lib/cyrus/tls_sessions.db" "./lib/cyrus/user" "./spool/cyrus/"
"./spool/sieve" "./lib/amanda"
} 1

venus home /home {
  comp-user-tar
  include "./debian"
} 1
----

/etc/amanda/DailySet1/amdump-wrapper is as follows:

----
#!/bin/bash

SSH_KEY=/etc/amanda/DailySet1/id_rsa
TARGET=root AT venus.gino DOT cl
CREATE=/etc/amanda/DailySet1/ctsnapshot
REMOVE=/etc/amanda/DailySet1/rmsnapshot

# Connect to the target host and create the snapshot.

/usr/bin/ssh -q -i $SSH_KEY -o 'BatchMode yes' $TARGET $CREATE

# Do the backup

/usr/sbin/amdump DailySet1

# Connect to the target host and remove the snapshot.

/usr/bin/ssh -q -i $SSH_KEY -o 'BatchMode yes' $TARGET $REMOVE


----

/etc/amanda/DailySet1/ctsnapshot is as follows:
----
#!/bin/bash

SNAP_SIZE=500M
SNAP_NAME=snap
VOL_GROUP=/dev/vg00
SRC_VOLUME=var
SNAP_SOURCE=$VOL_GROUP/$SRC_VOLUME
SNAP_VOLUME=$VOL_GROUP/$SNAP_NAME
SNAP_MOUNT=/mnt/$SRC_VOLUME

# Create mountpoint for the snapshot volume.

if [ ! -d "$SNAP_MOUNT" ]; then
        mkdir -p $SNAP_MOUNT
fi

# Snapshot the volume. 500M room for changes should be enough.

sync && sleep 1 && sync && sleep 1 && sync
/usr/bin/nice -n -19 /sbin/lvcreate -s -L $SNAP_SIZE -n $SNAP_NAME
$SNAP_SOURCE >& /dev/null || ( echo "Error creating snapshot of
$SNAP_SOURCE: $?" && exit 1 )

# Mount the snapshot.

/bin/mount -o ro $SNAP_VOLUME $SNAP_MOUNT || ( echo "Error mounting
snapshot of /var: $?" && exit 1 )


-

and /etc/amanda/DailySet1/rmsnapshot is as follows:
----
#!/bin/bash

SNAP_NAME=snap
VOL_GROUP=/dev/vg00
SRC_VOLUME=var
SNAP_VOLUME=$VOL_GROUP/$SNAP_NAME
SNAP_MOUNT=/mnt/$SRC_VOLUME

# Unmount the snapshot and remove the volume.

( /bin/umount $SNAP_MOUNT || ( echo "Error unmounting $SNAP_MOUNT: $?"
&& exit 1 )) && ( /sbin/lvremove -f $SNAP_VOLUME >& /dev/null || ( echo
"Error removing volume $SNAP_VOLUME: $?" && exit 1 ))

# Trash the mount point.

if [ -d "$SNAP_MOUNT" ]; then
        rmdir $SNAP_MOUNT
fi


----

-- 
Maurice Poisson Adriasola <mpoisson AT aconcagua DOT cl>

<Prev in Thread] Current Thread [Next in Thread>
  • Backup after LVM snapshot, Maurice Poisson Adriasola <=