Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'd like to backup my system without turning it off. The system clone should also able to run in an other machine.

I've tried to "dd" the entire system partition on another disk, after that I'm ensured that there's no administrative tasks launched. I think I had to tell to the grub to boot on that disk, so I've executed the command:

grub-install  /dev/sdc1 

but I got this error:

The file /boot/grub/stage1 not read correctly.

I know that I am doing is not very clean, so have you a good solution to reach my goals or a idea to solve the grub problem?

share|improve this question
    
If you have to keep it running, that implies that it's actually doing something. If that's the case, then it's almost certain that the content of your system will be changing during the backup. This makes the results somewhat unpredictable - test a lot before using in production. –  Joe Nov 15 '12 at 0:43
add comment

3 Answers 3

up vote 8 down vote accepted

There are several options that each have tradeoffs. You can not use dd to clone a filesystem while it is mounted read/write or the clone will end up corrupt since the source is being changed during the copy so the destination will be partially out of date and partially not. If you really want to be able to use dd to hot copy a partition, you can do so with LVM snapshots. This requires that you have installed the system using LVM in the first place, but then you can create a snapshot at any time, and since the snapshot is frozen and not mounted, you can safely dd the snapshot, then remove the snapshot. The other down side to using dd is that it wastes time copying all of the unused space in the volume, and requires the destination be at least as large, even if most of the source is unused.

Rather than use dd, you can simply use traditional backup tools such as tar or dump to backup the snapshot. This has the advantage of not wasting time copying free space, and can be restored to a smaller partition as long as it has space for the files. You can also extract only some of the files to do a partial restore. You also don't have to use LVM with this method: as long as you are reasonably sure that no files are being modified when you make the backup, it is safe to do on a mounted filesystem. The worst thing that can happen is that an individual file that is modified during the backup will be corrupt, rather than the entire backup being corrupt, as can happen with dd.

As you seem to have realized, after restoring the filesystem, you still need to reinstall grub to get the system to boot. I'm not sure why you got that error when you tried, but it seems you were using grub-legacy, since grub2 does not have a stage1.

share|improve this answer
    
I did not use LVM, but I could, I'm looking for a durable solution. is that it is sufficient to copy all system tree (excluding proc) and then modifying the grub? –  Gael Nov 8 '12 at 15:12
    
@Gael, it is sufficient to copy all of the files, and reinstall grub, yes. You may also need to update the UUIDs in /etc/fstab. Note that if you are using tar you want to exclude not just /proc, but also /dev, /sys, and /run as well, or use the --one-file-system switch to stop it from descending into other filesystems. –  psusi Nov 8 '12 at 15:37
    
thank you, I will try with tar. This solution may allow a full control of the backup. –  Gael Nov 8 '12 at 16:16
add comment

I think there is no real option to do a reliable backup of a running system on the device level: Your file system would get too corrupted as you cannot freeze the current state and the backup operation takes a significant amount of time.

However you could try following options:

  1. Run the system within a VM. You can create a snapshot of the system and then do a backup of this snapshot. When backup is done, snapshot can be easily discarded. This solves the problems mentioned above.
  2. Do the backup on file-system level, not on device level. I can recommend rsnapshot for this.
share|improve this answer
    
I'm looking for a solution which allow to backup a system without turning it off. So, regardless of the method used, the system will must be runinng. If it's sufficient to copy just the filesystem to copy the system, rsync will do the job, what brings rsnapshot? –  Gael Nov 8 '12 at 15:20
    
rsnapshot provides you with as many incremental multiple backups as you need (hourly, daily, weekly, monthly) and backups are available in plain full directory structure despite they are incremental. –  Vilmantas Baranauskas Nov 9 '12 at 10:02
add comment

Using something like rsync or tar to copy the partition may be simpler. I would mount the partition on a second mount point like /mnt before the copy. These options also allows you to change the partition size or type. You may have structures on additional partitions as well. I often have separate partitions for /var and /usr. These will need to be considered as well.

You may need to dig into the grub documentation to determine how to target the disk and partition correctly. install-grub may make incorrect assumptions which don't do what you want.

There are tools like mondo which allow you to create a bootable recovery CD with your OS installed on it.

share|improve this answer
    
I was using dd because I was saying to me that other file copy tools will only copy files, not mbr and the partition table. I threw a glance on mondo, and it could the simplest solution. Thank you –  Gael Nov 8 '12 at 15:10
    
@Gael If you are only cloning SD1, you wont get the MBR. There are a number of tools which will update the MBR if needed. It normally already has code to look for a boot record. –  BillThor Nov 9 '12 at 1:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.