[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Clone of hard drive



>>>>> "Jay" == Jay Kelly <neutec@pacbell.net> writes:

    Jay> Is it possible to clone my linux hard drive to an image or to
    Jay> another drive?  This way in the event of hard drive failure I
    Jay> can swap drives and be right back up. If it is, how would I
    Jay> go about it?

 Don't use `dd' - it won't work well if the two drives are not the
 same size.  Partition and format the new drive using the standard
 tools, then use a `cpio' archive or `cpio' in copythrough mode to
 clone the filesystem.  (RTFM `cpio'.)

 GNU `cp' or the BusyBox `cp' from the _Potato_ `boot-floppies' will
 also work, if you use the `-a' switch and are careful not to try and
 copy `/proc' and other things that shouldn't get copied over.  Don't
 try this with the `boot-floppies' `cp' from before around version
 2.2.8 (iirc) or so - it would flatten the filesystem and would not
 preserve hard links.  (does now though - I saw to that.)

  "make-cpio-archive"
8<------------------------------------------------------------>8
#!/bin/bash
find / -print0 |
 grep --invert-match --extended-regexp --null-data \
      --file=/root/make-cpio-archive.exclude-patterns |
 cpio --create --format=crc --null --reset-access-time --block-size=10 |
 gzip --best > /tmp/system-snapshot_$(date +%Y.%m.%d).cpio.crc.gz
8<------------------------------------------------------------>8

   "make-cpio-archive.exclude-patterns"
8<------------------------------------------------------------>8
^/proc/.*
^/tmp/.*
^/lost+found
^/boot/lost+found
^/var/cache/apache/.*
^/var/cache/apt/.*\.deb
^/var/log/.*\.log
^/var/log/\(amanda\|apache\|gdm\|ksymoops\|mailman\|news\|sendfile\|wu-ftpd\)/.*
^/var/log/\(syslog\|smb\|nmb\|messages\|mail\|lpr\|debug\|dmesg\).*
^/var/lock/\.LCK.*
^/var/run/.*\.pid
^/var/run/\(ndc\|utmp\)
^/var/samba/.*
\.bash_history
\.gnome-errors
.*~
/\.saves-.*
/\.#.*
/\.netscape/cache/.*
8<------------------------------------------------------------>8

-- 
Those who do not study Lisp are doomed to reimplement it - Poorly.
A few months in the laboratory often saves several hours at the library.

mailto:karlheg@debian.org (Karl M. Hegbloom)



Reply to: