Difference between revisions of "Migrating a linux root partiton"

From Blue-IT.org Wiki

(==Rsync)
Line 11: Line 11:
  
  
===Rsync=
+
=Rsync=
 
A method for a backup that checks, if the selected partition is mounted:
 
A method for a backup that checks, if the selected partition is mounted:
  

Revision as of 13:32, 18 August 2006

TAR

A method that only copies files and dirories from root "/":

$ mkfs -t ext2 /dev/hda4 
$ mkdir /mnt/temp 
$ mount -t ext2 /dev/hda4 /mnt/temp 
$ cd / 
$ tar lcf - .|(cd /mnt/temp; tar xpvf - )

from Linux and XFS HowTo


Rsync

A method for a backup that checks, if the selected partition is mounted:

mkdir -p /${ROOTDIR}
if test -e /${ROOTDIR}/itsroot
then echo ${ROOTDEV} already mounted as /${ROOTDIR}...
    echo ---------------------------------------------------------------
else
       if mount -rv ${ROOTDEV} /${ROOTDIR}
       then echo - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            echo Mounted ${ROOTDEV} on /${ROOTDIR} ...
            echo ---------------------------------------------------------------
       else
               if mount -r -o bind / /${ROOTDIR}
               then echo - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                    echo Mounted ${ROOTDEV} on /${ROOTDIR} VIA BIND - OK.
                    echo ---------------------------------------------------------------
                       if test -e /${ROOTDIR}/itsroot
                       then echo Seams to be the right directory - OK.
                       else echo ERROR mounting  ${ROOTDEV} on /${ROOTDIR};clear; canceled;
                       fi

               else echo ERROR mounting  ${ROOTDEV} on /${ROOTDIR};clear; canceled;
               fi
       fi
fi
rsync -a --progress --delete /${ROOTDIR}/. /${BACKUPDIR}/${ROOTDIR}/.