linux-lvm.redhat.com archive mirror
 help / color / mirror / Atom feed
From: "Stuart D. Gathman" <stuart@bmsi.com>
To: LVM general discussion and development <linux-lvm@redhat.com>
Subject: [linux-lvm] Backup with snapshots
Date: Thu, 21 Jun 2007 10:54:54 -0400 (EDT)	[thread overview]
Message-ID: <Pine.LNX.4.44.0706211046300.17457-100000@bmsred.bmsi.com> (raw)

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.

                 reply	other threads:[~2007-06-21 14:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.44.0706211046300.17457-100000@bmsred.bmsi.com \
    --to=stuart@bmsi.com \
    --cc=linux-lvm@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).