* [linux-lvm] Backup with snapshots
@ 2007-06-21 14:54 Stuart D. Gathman
0 siblings, 0 replies; only message in thread
From: Stuart D. Gathman @ 2007-06-21 14:54 UTC (permalink / raw)
To: LVM general discussion and development
I have been manually running this script to make backups of a live
application system:
-----------lvbackup------------------
#!/bin/sh
if test "$#" -lt 2; then
echo "Usage: $0 SRCLV DESTDIR"
exit 2
fi
lvpath="$1"
media="$2"
shift 2
if test -e "${media}/BMS_BACKUP_V1"; then
:
else
echo "${media} is not formatted as a backup drive"
exit 1
fi
lvname="${lvpath##*/}"
lvname="${lvname##*-}"
snapname="${lvname}_SNAP"
snappath="${lvpath}_SNAP"
tmpdir="/mnt/${snapname}"
destdir="${media}/${lvname}/current"
lvcreate -s -L 2G -n "$snapname" "$lvpath" || exit 1
mkdir -p "$tmpdir" "$destdir"
mount -r "$snappath" "$tmpdir"
mount -o remount,rw "${media}"
rsync -ravXHx "$@" "${tmpdir}/" "${destdir}"
umount "$tmpdir"
mount -r -o remount,ro "${media}"
lvremove "$snappath"
---------------------------------------------
My question concerns the last line. I asks me if I really want
to remove the LV.
1) Is it intended usage to create and destroy snapshots every day like this?
2) Am I missing a step? Am I supposed to deactivate the snapshot first?
3) If I deactivate it, can I leave it allocated, and will it resync with
source LV when I reactivate it?
4) Or am I just supposed to use "-f" on the lvremove? How do I ensure
that no stray processes still have the LV open. The umount will fail
if stray processes are still in the filesystem, but will the lvremove -f
still fail if something has the block device open?
I just feel nervous turning scripts that change LVs loose in cron, and
want to make it as safe as possible.
--
Stuart D. Gathman <stuart@bmsi.com>
Business Management Systems Inc. Phone: 703 591-0911 Fax: 703 591-6154
"Confutatis maledictis, flammis acribus addictis" - background song for
a Microsoft sponsored "Where do you want to go from here?" commercial.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-06-21 14:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-21 14:54 [linux-lvm] Backup with snapshots Stuart D. Gathman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).