Paul Bijnens wrote:
Following up on myself... (as usual on mondays)...
And again following up on myself... ;-)
Paul Bijnens wrote:
The good news is that Redhat just fixed this very recently.
in device-mapper-1.01.01-1.RHEL4, which you can install by up2date
or "yum update device-mapper".
https://rhn.redhat.com/errata/RHEA-2005-188.html says:
> [...]
> - The inodes created in the /dev/mapper directory when devices are
> activated are now accessible by the 'disk' group used by some
> backup tools.
The bad news is that I just rebooted a Centos 4 under VMWare to test
it, with this patch installed, and the permissions are still bad.
brw------- 1 root root 253, 0 Jun 20 2005 /dev/mapper/VolGroup00-LogRoot
Maybe the news is not as bad neither.
Suddenly I noticed that when I make a snapshot of a logical volume
the permission ARE indeed correct:
$ cd /dev/mapper
$ ls -l *pace*
brw------- 1 root root 253, 1 Jun 20 19:00 VolGroup00-LogSpace
brw-rw---- 1 root disk 253, 6 Jun 22 17:25 VolGroup00-LogSpace-real
brw-rw---- 1 root disk 253, 7 Jun 22 17:25
VolGroup00-_space--2005--06--22--17.25.snap
brw-rw---- 1 root disk 253, 5 Jun 22 17:25
VolGroup00-_space--2005--06--22--17.25.snap-cow
The script that makes these snapshots is already in use some months now
and I never really looked into the files it created in /dev/mapper/ either.
It's only now that I notice that creating a snapshot, also creates
a *-real and a *-cow file. A quick google does not get me any info
about the meaning of those files either.
The script creates a snapshot with a variable name, including
the data-time in the name, making it more selfdocumenting.
For my backups, I mount those snapshots in the /snap directory:
mount -o ro /dev/VolGroup00/_space-...snap /snap/_space-...snap
create a simple symlink to it, so that I can use that fixed name
in the disklist in amanda:
ln -s /snap/_space-2005-06-22-17.25.snap /snap/_space
and with amanda I make gnutar backups of them with this DLE:
the.host.com /space /snap/_space comp-user-tar 1
The snapshots stay mounted for the rest of the day, so that
people can restore files from the previous day, without using amanda
(and my help to insert the tape).
I never tried to use dump instead of gnutar on the snapshotdevices,
but I guess it should work out fine.
At least the permissions are OK there.
Because I do not have an older system without the update mentioned
above, I can't verify if these permissions settings are new or not.
Attached is the script that I use to manage the snapshots.
You can base your config on this. (Any feedback on the script
itself is welcome too.)
Crontab runs this 1 minute past midnight as root. And amanda starts
5 minutes past midnight.
--
Paul Bijnens, Xplanation Tel +32 16 397.511
Technologielaan 21 bus 2, B-3001 Leuven, BELGIUM Fax +32 16 397.512
http://www.xplanation.com/ email: Paul.Bijnens AT xplanation DOT com
***********************************************************************
* I think I've got the hang of it now: exit, ^D, ^C, ^\, ^Z, ^Q, F6, *
* quit, ZZ, :q, :q!, M-Z, ^X^C, logoff, logout, close, bye, /bye, *
* stop, end, F3, ~., ^]c, +++ ATH, disconnect, halt, abort, hangup, *
* PF4, F20, ^X^X, :D::D, KJOB, F14-f-e, F8-e, kill -1 $$, shutdown, *
* init 0, kill -9 1, Alt-F4, Ctrl-Alt-Del, AltGr-NumLock, Stop-A, ... *
* ... "Are you sure?" ... YES ... Phew ... I'm out *
***********************************************************************
#!/bin/sh
# Create a snapshot for the amanda backups
USAGE="$0 [-r] [-n] [-s 1g]"
REMOVEONLY=
DONOTREMOVE=
SIZE=1g
while getopts nrs: i
do
case $i in
n) DONOTREMOVE=donotremove;;
r) REMOVEONLY=removeonly;;
s) SIZE=$OPTARG ;;
\?) echo $USAGE
exit 2 ;;
esac
done
shift `expr $OPTIND - 1`
PATH=/sbin:/bin:$PATH; export PATH
lvs --noheadings --options vg_name,lv_name,origin --sort -origin |
while read vg_name lv_name origin
do
lv__name=`echo $lv_name | sed -e 's/-/--/g'`
mountpoint=`mount | grep "$vg_name-$lv__name" | sed -e 's/.* on //' -e 's/
type .*//'`
case $mountpoint in
/) continue ;; # snapshots for root fs are not working (??)
/tmp) continue ;; # neither for /tmp
"") continue ;; # e.g. swap
esac
if [ -n "$origin" -a -z "$DONOTREMOVE" ]
then
if test -e /dev/$vg_name/$lv_name
then umount /dev/$vg_name/$lv_name
fi
rmdir /snap/$lv_name
lvremove -f /dev/$vg_name/$lv_name >/dev/null || {
echo Remove Snapshot $SNAPNAME error
exit 1
}
continue
fi
if [ -n "$origin" -o -n "$REMOVEONLY" ]
then continue
fi
mountpoint=`echo $mountpoint | tr '/' '_'`
SNAPNAME=$mountpoint-`date +%Y-%m-%d-%H.%M`.snap
lvcreate --snapshot --size $SIZE --name $SNAPNAME \
/dev/$vg_name/$lv_name >/dev/null || {
echo Create Snapshot $SNAPNAME error
exit 1
}
SNAPDIR=/snap/$SNAPNAME
mkdir $SNAPDIR
rm -f /snap/$mountpoint
ln -s /snap/$SNAPNAME /snap/$mountpoint # symlink for Amanda
mount -o ro /dev/$vg_name/$SNAPNAME $SNAPDIR
done
|