9

Is it possible to clone an Ubuntu system and if any changes are made to original system, those should be replicated to the one cloned? I need to have backup support if original one gets down. In my case, Ubuntu is a cloud server.

Please guide me step by step.

Braiam
  • 67,791
  • 32
  • 179
  • 269
user3215
  • 5,383

6 Answers6

4

I would use rsync with SSH keys over the network and set it to run frequently with cron. This way, only the changes need to be transmitted.

Format taken from how do I do mass installs?

#!/bin/bash
rsync -avx --exclude=/proc --exclude=/dev --exclude=/tmp --exclude=/sys --delete-after root@${host}:/ /

On the machine that will serve as a backup, make a file named /etc/cron.daily/backup-pull then make it executable sudo chmod +x /etc/cron.daily/backup-pull. Replace ${host} with the IP of the original system.

You'll have daily syncs of the original server to this one. You could also do cron.hourly instead of cron.daily if you're really paranoid.

maco
  • 15,892
3

Please refer to https://help.ubuntu.com/community/BackupYourSystem/SimpleBackupSuite and https://help.ubuntu.com/community/BackupYourSystem , also Comparison of backup tools .

If you want to only save the changes in packages installed, etc, you can use dpkg --get-selections > installed_packages, and restore those with apt-get update && dpkg --set-selections < installed_packages && apt-get upgrade.

To backup your user files, it is sufficient to copy the /home directory to the remote server, refer to the second link.

evgeny
  • 9,575
  • 1
    It's good for backing up files & directories. I'm thinking to clone ubuntu cloud server. – user3215 Oct 13 '10 at 10:30
  • You probably don't want to be using a synchronisation solution for backup, since any problems with the original system will be mirrored in the backup. Using the solution proposed by Evgeny Martynov above would be the safest way to backup your system. –  Oct 13 '10 at 10:49
  • I think it's possible to sync the directory '/' with new ubuntu installation after copying all the packages(dpkg --set-selections < installed_packages) – user3215 Oct 13 '10 at 11:16
  • 1
    It is, however that will not copy your /home stuff and any files that do not belong to a package but are in /. – evgeny Oct 13 '10 at 11:18
  • 1
    My major requirement is, if one system is down then I could immediately get up the other with all the packages, files and directories. – user3215 Oct 13 '10 at 11:21
  • Then the foolproof way would be using rsync. It will only transfer the differences between the systems, as far as I am aware. – evgeny Oct 13 '10 at 11:32
  • Unless you're surgical about it, rsync may transfer more then you intended. You wouldn't want to transfer /etc/network/interfaces, but you might want to transfer /etc/resolv.conf. in most cases. The requirements here almost sound like a Configuration Management problem and not simply a "clone the filesystem" prblem. – Stefan Lasiewski Oct 13 '10 at 17:34
  • I'm not sure what to use rsync, dd, ddrescue, clonezilla or what?. What I shouldn't copy?. It may copy ip & mac address of the interface, and don't know if would cause any problem if fstab file is copied. – user3215 Oct 15 '10 at 09:33
  • If it's a cloud server it should clone over network? – user3215 Oct 15 '10 at 09:51
  • These cloning process should not harm the orginal one. – user3215 Oct 15 '10 at 10:15
1

You probably want to use something like drbd. Probably combined with something like Heartbeat. More info about that on the Linux High Availability site.

I suppose some cloud or cluster solutions come with similar functionality built-in or available as extensions, you might want to dig into their documentation.

JanC
  • 19,422
  • I couldn't understand how using drbd, Is it good for server. – user3215 Oct 15 '10 at 09:35
  • Yes, it's mostly used for servers. That's what the Linux-HA site is about: automatic failover to another server in case the first one crashes or whatever. And 'drbd' is the kernel driver & tools that take care of replicating all changes to the other computer automaticly (it works a bit like RAID 1, except the mirror disks are in another computer). – JanC Oct 15 '10 at 10:32
  • I realized drbd will suit well for my requirement as you said. – user3215 Oct 22 '10 at 07:19
1

The data itself will need to be backed up by other means but for repeatable configurations I would really look at tools like preseed and puppet. With puppet and preseed you also get the benefit of some level of self documentation on the configurations as well.

1

You should use virtualisation. Software like KVM or Xen allow You to create a virtual machines, which are like normal machines, but You can clone them and copy to another physical machine.

I cannot guide You step by stem because every situation is different. I recommend read a documentation on these sites and ask when You encounter a specific problem.

0

Check out remastersys. Remastersys is a tool that can be used to do 2 things with an existing Debian, Ubuntu or derivative installation.

  1. It can make a full system backup including personal data to a live cd or dvd that you can use anywhere and install.
  2. It can make a distributable copy you can share with friends. This will not have any of your personal user data in it.

http://www.geekconnection.org/remastersys/index.html