The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Clone local drive with rsync?? Advice needed

Discussion in 'Data Protection' started by CaMer0n, Jul 6, 2008.

  1. CaMer0n

    CaMer0n Well-Known Member

    Joined:
    Nov 8, 2004
    Messages:
    59
    Likes Received:
    0
    Trophy Points:
    6
    Can anyone explain how I might go about backing up an entire (server/drive) to another one in the same machine - at regular intervals? (ie. cron)

    Basically, the main hard-drive in the system has been a little unreliable lately, and I'd like to clone it (ie. WITHOUT compression/tars etc) so in the event of a failure, the 2nd drive could be swapped over and everything would run as usual.

    Here's the physical drives of the system:
    hda: WDC WD2500JB-75FUA0, ATA DISK drive
    hdb: ST3250820A, ATA DISK drive
    hdc: SAMSUNG CD-ROM SC-148A, ATAPI CD/DVD-ROM drive
    hda: max request size: 1024KiB
    hda: 488281250 sectors (250000 MB) w/8192KiB Cache, CHS=30394/255/63, UDMA(100)
    hda: cache flushes supported
    hdb: max request size: 1024KiB
    hdb: 488397168 sectors (250059 MB) w/8192KiB Cache, CHS=30401/255/63, UDMA(100)
    hdb: cache flushes supported
    hdc: ATAPI 48X CD-ROM drive, 128kB Cache, UDMA(33)


    hda contains everything.

    /dev/hda5 7.9G 385M 7.1G 6% /
    /dev/hda1 122M 33M 83M 29% /boot
    none 506M 0 506M 0% /dev/shm
    /dev/hda6 189G 88G 92G 49% /home
    /dev/hda7 1012M 319M 642M 34% /tmp
    /dev/hda2 20G 4.0G 15G 22% /usr
    /dev/hda3 9.9G 424M 9.0G 5% /var
    /tmp 1012M 319M 642M 34% /var/tmp

    And I'd like to copy everything (partitions, files, boot record etc) to hdb which has just been added by the datacenter.

    So, can rsync do this? and If so, with what command?

    Sorry for all the questions, but after researching on the web, and in this forum, I haven't found a clear answer.. but I have learned that done incorrectly, I could seriously mess up the existing data. :confused:

    Thanks in advance.
     
  2. troxalias

    troxalias Well-Known Member

    Joined:
    Nov 21, 2001
    Messages:
    96
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Athens - Greece
    *** I TAKE NO RESPONSIBILITY FOR THE INSTRUCTIONS BELOW ***
    As i don't feel very comfortable with rsync, i would use a "dump'n'restore" approach. So...
    1. Copy the mbr and partition table from hda to hdb with the command
    Code:
    dd if=/dev/hda of=/dev/hdb count=16
    2. create a dummy chroot dir with the commands
    Code:
    mkdir -p /home/SECONDDRIVE/boot
    mkdir /home/SECONDDRIVE/home
    mkdir /home/SECONDDRIVE/usr
    mkdir /home/SECONDDRIVE/var
    
    3. create file system on the new drive
    Code:
    newfs /dev/hdb1
    newfs /dev/hdb2
    newfs /dev/hdb3
    newfs /dev/hdb5
    newfs /dev/hdb6
    newfs /dev/hdb7
    
    4. Mount the new partitions to the appropriate folders with the command:
    Code:
    mount /dev/hdb5 /home/SECONDDRIVE/
    mount /dev/hdb1 /home/SECONDDRIVE/boot
    mount /dev/hdb2 /home/SECONDDRIVE/usr
    mount /dev/hdb3 /home/SECONDDRIVE/var
    mount /dev/hdb6 /home/SECONDDRIVE/home
    
    5. Dump and restore data on the new drive with the commands:
    Code:
    dump cf - / | (cd /home/SECONDDRIVE/; restore xf - )
    dump cf - /boot | (cd /home/SECONDDRIVE/boot; restore xf - )
    dump cf - /usr | (cd /home/SECONDDRIVE/usr; restore xf - )
    dump cf - /var | (cd /home/SECONDDRIVE/var; restore xf - )
    dump cf - /home | (cd /home/SECONDDRIVE/home; restore xf - )
    
     
  3. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    Bear in mind that this would likely generate corrupt MySQL databases if you have them stored on the drive. These need to be dumped to text files beforehand and then restored from the dumps.
     
  4. CoolMike

    CoolMike Well-Known Member

    Joined:
    Sep 6, 2001
    Messages:
    307
    Likes Received:
    0
    Trophy Points:
    16
    Is there any other solution to replicated a disc during the main disk is in normal operation? This would be a very good solution to make backups, in case a disk is broken, you just replace the disk and everything is running again. No need for OS reload, WHM installation and Cpanel Backup restore.

    Or is the replication to disk I/O intensive?

    Michael
     
  5. CaMer0n

    CaMer0n Well-Known Member

    Joined:
    Nov 8, 2004
    Messages:
    59
    Likes Received:
    0
    Trophy Points:
    6
    thanks troxalias,

    I got to step 3, and get '-bash: newfs: command not found
    '.

    Was I meant to substitute "seconddrive" with something in step2?

    Thanks.. and sorry for the noob questions.

    Cameron
     
  6. tomdchi

    tomdchi Well-Known Member

    Joined:
    Feb 24, 2008
    Messages:
    114
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Atlanta, GA
    cPanel Access Level:
    DataCenter Provider
    How about using RAID? I have never used before but am about to with new server.
     
  7. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    RAID isn't a reliable method for duplicating data for this purpose and doesn't address the issue of MySQL database corruption. To avoid that, you're better off using a backup MySQL database that will duplicate transactions in realtime. Setting that up is straightforward.
     
  8. CaMer0n

    CaMer0n Well-Known Member

    Joined:
    Nov 8, 2004
    Messages:
    59
    Likes Received:
    0
    Trophy Points:
    6
    chirpy, what would you recommend for cloning/mirroring a drive?

    rsync, dd or maybe some other software?

    thanks
     
  9. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    If you want remote synchronisation, then rsync would probably by the best way with periodic updates from the liver server. Together with a duplicate MySQL server to keep that up to date.
     
  10. devGOD

    devGOD Well-Known Member

    Joined:
    Oct 18, 2003
    Messages:
    122
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Atlanta, GA
    can you post a how-to, showing how you would do the mirroring of another drive
     
Loading...

Share This Page