Clone ubuntu system and auto replicate the changes

Thyagaraj03 used Ask the Experts™
Is it possible to clone a ubuntu server and if any changes made to original system must be replicated to the one cloned?. This I need to have backup support if original one gets down. In my point the ubuntu is a cloud server.

I tried "ddrescue /dev/sda /dev/sdb" on my vbox and it worked fine. The confusion is that from which disk it boots and will I have multiple boot entries at the startup?. Is it possible to use ddrescue to clone the remote hard disk?.

I want to replicate the changes made on orginal hard disk to the duplicate and so I thought of scheduling a cron job using "rsync" but after system restart the devices /dev/sda and /dev/sdb might be interchanged and it may cause problem.

For cloning, taking the server off for few minutes/hrs is mandatory?. Can't I accomplish this without taking the server off?. It should not cause any problem to the orginal disk
 plz guide me step by step.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Hi. you can accomplish exactly what you are looking for using drbd and heartbeat, but the process is not simple. Please read:

Using dd is a bad idea because the filesystem must be taken offline to properly clone the hard drive resulting in server downtime. DRBD can replicate it on the fly.


It seems a bit difficult to understand DRBD. If possible could you guide me step by step.

DRBD is not a simple system. If you do not fully understand how it works, when or if something breaks, you will be in serious trouble. The only thing  can recommend is for you to read the manual:

and to read tutorials how to setup drbd such as this one:
Should you be charging more for IT Services?

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!


Ok it will take some time to read and I'll try to understand DRBD. It's good.

 Again what happens if I use 'ddrescue' without taking the server offline?. I did like this on my vbox virtual machine and I've my virtual hard disk cloned. Would it cause any problem to orginal disk?
Since your server is "in the cloud", do you have the capability of taking snapshots? I know this can be done in VMWare, but I'm not familiar with "the cloud".  If you can take snapshots, then you could 'dd' the snapshot image periodically without having to take it offline.
If your server is in the Amazon cloud, check out their EBS (Elastic Block Storage) which allows for "EBS Snapshots":
(Scroll down to the section called "Amazon EBS Snapshots")

@Thyagaraj03:  Again what happens if I use 'ddrescue' without taking the server offline?. I did like this on my vbox virtual machine and I've my virtual hard disk cloned. Would it cause any problem to orginal disk?

The original disk will not be damaged, but your backup will have a high probability of not being usable.

Consider this:

Server1Online - you start dd_rescue, dd_rescue starts copying the contents of your mysql database files;
mysql writes to the database
Backup has half the unmodified database and then half of the new database <- in this case, mysql will not start anymore.

This is a relatively good case, what is worse is the filesystem makes changes... the file system will be corrupt and unbootable.

Use the partimage software from to clone the other server and then use rsync to update using cron...


I think DRBD would suit well for my requirement as suggested by 'johnmchan' here. I'm trying this on my virtual machines and I'm getting some errors while making primary. I hope DRBD will not harm file system, is it?.


I have a bit idea of DRBD but do not understand what is 'heartbeat' and what's the difference between DRBD and heartbeat
I a DBRD environment, DRBD mirrors a partition between two machines allowing only one of them to mount it at a time. Heartbeat on both machines checks each other to detect if they are up..


I think I'll have to add a separate partition/hard disk to promote DRBD on each system. I didn't understand, won't I have complete / directory replicated between 2 servers. I followed the links:
If all the systems have same configuration, clone the disk and apply it to all of them, try it on one system , if it works do it for all, it might save u a lot of time.

1- use Mondo Rescue to clone linux systems:
in order to image your system and create bootable CD/DVD download mondo for your distro  more info read this manual

2- You can use dd also. dd if=/dev/somedisk of=/dev/somedestination

3- rsync scripting

4- netcat
On the source server: (cd / && tar -cvf - ) | nc 2000
On the destination:: nc -l -p 2000 | tar -xvf -
You can also use partimage this is similar to ghost but has more intelligence as follows

Fast. Since file fragments are not "hunted down" head movement is minimized allowing optimal use of the disk's cache.

Fast. Since only allocation clusters which are in use is read and saved.

Read only. None of the data being backed up is modified. This includes meta-data like last-access date. Preserves integrity of source partition.

Multi file synchronization. If there are multiple files that make up a fileSet, no file in the set will be out of sync with the other files.

Destination flexibility. Backup media can be a file on another partition on the same disk, another local disk or a network attached file.

Fast Restore. Data is simply flowed onto the disk optimizing the disk cache and minimizing disk seek time.

Simple restore. There is only one media to restore. No decision regarding order of restoring multiple back media.

No recover of deleted files. Files that were deleted at the time of the backup are not on another media that needs to be restored causing deleted files be resurrected

"Accounting is unaffected".

recovery to alternate partition Excellent choice for mirroring the file system on another disk or at another location.



I'll try this.
Most Valuable Expert 2015

This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial