I'd like to make backup on external drive of LVM2 logical volume in dd
manner.
Approach I consider is to
- make lv on external drive with identical size
- copy with
dd
(Please let me know if you see something really wrong in such approach. I need something reliable and fast.)
I would like to automate the whole process; this is what I have:
# Sanity check that lv is not used
lvuses="$( lvdisplay -c /dev/mapper/vgA-AA | cut -d ':' -f 6 )"
if [ $lvuses -gt 0 ]; then exit 1 ; fi
#obtain lv size (in sectors)
lvsize="$( lvdisplay -c /dev/mapper/vgA-AA | cut -d ':' -f 7 )"
#create destination
lvcreate -L "${lvsize}s" vgB -n BB || exit 1
# copy
dd if=/dev/mapper/vgA-AA of=/dev/mapper/vgB-BB
Is it all right? Have I missed something?
(In my case vgA-AA is LVM snapshot and I would like to backup it to external drive and take this drive to other geographical location)
s
suffix in-L
option : http://unix.stackexchange.com/questions/34767/lvm2-lvcreate-l-what-does-s-s-suffix-stand-for/34773 – Grzegorz Wierzowiecki Mar 22 '12 at 22:21dd if=/dev/mapper/vgA-AA of=/dev/mapper/vgB-BB
is equivalent tocat </dev/mapper/vgA-AA >/dev/mapper/vgB-BB
, and may be slower or faster depending on the underlying hardware configuration. – Gilles 'SO- stop being evil' Mar 22 '12 at 23:51