[CS-FSLUG] Linux Drive Cloning
Karl Kleinpaste
karl at kleinpaste.org
Mon Jul 26 07:50:50 CDT 2010
Just FYI, because it might be useful to some folks... I've attached the
script I use these days for backup. It uses rsync to clone partitions.
My partition layout looks like this:
/dev/sda1 * 1 26 208813+ 83 Linux
/dev/sda2 27 3943 31463302+ 83 Linux
/dev/sda3 3944 7860 31463302+ 83 Linux
/dev/sda4 7861 77825 561993862+ 5 Extended
/dev/sda5 7861 9950 16787893+ 82 Linux swap / Solaris
/dev/sda6 9951 10995 8393931 83 Linux
/dev/sda7 10996 77825 536811943+ 83 Linux
Filesystem 1M-blocks Used Available Use% Mounted on
/dev/sda2 30244 20702 9543 69% /
/dev/sda1 198 77 122 39% /boot
/dev/sda3 30244 20503 9742 68% /.alt
/dev/sda6 8069 1589 6481 20% /usr/local
/dev/sda7 516005 108378 407627 22% /home
Notice sda[23]. I configure discs with 2 root filesystems. The current
root is of course on /. The previous incarnation of Fedora is on /.alt.
I do this on all my systems, as a way of preserving (especially)
configuration information as I upgrade from one release to the next, and
more than once I've recovered an interesting needed library from the
last incarnation that turned out to have been missing from a new one.
So, at the moment on this laptop, / is F13 on sda2, and /.alt is its old
F12 on sda3. At the end of this year when F14 comes out, I'll overwrite
F12 with it on sda3, and sda2 will become /.alt.
The script believes that it will find a clonable backup disc available.
It wants to be run either on my desktop (mesquite), which has a disc
mounted in an ordinary way, and for which the partitions are present as
though it were a complete system, echoing this layout under
/media/backup; or on my laptop (awol), for which I have a USB drive that
auto-mounts itself as 5 equivalent, non-hierarchical filesystems.
It has options:
# -a|--alt include /.alt
# -k|--kidding echo only
# -t|--test for dir existence before rsync
# -p|--progress indicators
I don't routinely backup /.alt because in principle it should not
change. The kidding option is for testing what the script should do,
and kidding is assumed if not run by root. The test option makes sure
that the expected destination directories are in place, which is needed
because sometimes things that I do with the detachable USB drive lead to
funny choices on the part of HAL for a mount point. Progress indicators
give just another rsync switch, usually not very useful.
The script requires recent bash because it uses associative arrays
(declare -A) to name filesystems to be backed up.
Embellish to taste.
--karl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: BACKUP.rsync
Type: application/x-sh
Size: 1645 bytes
Desc: disc cloning script
URL: <http://ofb.biz/pipermail/christiansource_ofb.biz/attachments/20100726/75bae83b/attachment.sh>
More information about the Christiansource
mailing list