2

I would like to backup my server. For example using dd:

dd if=/dev/md0 of=/some_network_share

I wonder if this image will be vary inconsistent if /dev/md0 is mounted? Would it be possible to convert such dd image to vdi drive and create working virtual machine? Using this command for example:

VBoxManage convertfromraw ImageFile.dd OutputFile.vdi 

Network traffic is disabled on firewall (there is only connection to/from one remote machine where image is copied).

6
  • 2
    Chances to get a consistent backup with this method are: 0% Mar 20, 2011 at 14:20
  • 3
    @mugen: Not if it's mounted ro.
    – Hello71
    Mar 20, 2011 at 14:50
  • 1
    Server backup to create a working virtual machine implies very much that it is mounted rw. Mar 20, 2011 at 15:00
  • @mugenkenichi, re consistent, if all I care about is creating a image to mount in a VM, and no-one is using the machine while dd is active, then would the above work?
    – IanVaughan
    Jan 3, 2012 at 13:48
  • 2
    Noone using the machine does not mean the disk content is not altered. Usually there are several processes running that do at least log something. LVM snapshots are a good way to go. Feb 16, 2012 at 7:51

5 Answers 5

2

If you are using LVM volumes (which you probably should be using in a production enviroment), there is a copy on write snapshot facility that can produce exact snapshots.

There's several commercial products that can do this, in some form or another - vmware vCenter Converter can make a virtual machine out of a live machine, Acronis TrueImage has a linux version of one of their enterprise products that supports live copies.

Otherwise, a hackish way to do it that might work would be to use rsync repeatedly until the differences are small enough that you can remount filesystems read only, rsync one last time, and then remount rw. I've never tried this on a raw filesystem image, but it works well on a directory structure.

1
  • We diced to install everything on VM from scratch and only export/import data from old machine. But I like idea of using rsync repeatedly. I herd it also from some one else. I think it should work. Jul 24, 2011 at 16:04
1

It depends on the method. The problem with imaging a running disk is there's no way to ensure consistancy - files change while you're working on them for one.

There's several approaches to avoid this - one is to use some way to make a snapshot of how files are at a very specific period of time and make a backup - windows has VSS, but linux / ext has no equivalent to that.

The other is to make the image off a non live system

So, no, unless its a OS or FS that can snapshot, its not a good way to go around doing things.

1
  • Linux has LVM snapshots, provided you are using LVM.
    – Stephanie
    Jul 11, 2011 at 17:05
0

Yes.

Don't do it.

The backup will not be usable. Even if your conversion succeed, you will have a hard time verifying the content.

0

I think the only way to get this to work would be to make a software(or possibly hardware if you're man enough to configure it) RAID 1 setup with another harddrive. From there, ensure that it's synced and then when it's time to take a backup image, take the second disk in the array out(with a script, not physically) and copy the second harddrive. This would probably have serious performance concerns depending on how smart your RAID is(if you have to completely resync the drive everytime the backup completes), but this is a way to do it without taking your server offline

0

I have actually done this and it works. It's fairly reliable, too, all things considered. Is it a good idea? No, probably not. You may lose data or end up with corrupt files. With an ext3 partitions, at boot, you will get a warning that the partition "was not cleanly unmounted, check forced." It will then run 'fsck'. It may take a long time for fsck to return the filesystem to a clean state, but it will get there. An ext4 filesystem will do this faster.

Think about it this way, a 'dd' of a live filesystem is equivalent of pulling the power plug from a server while it is running. If you pulled the power plug from a server would you expect that the filesystem will be ruined and that the machine will not boot again? Of course not. Well, unless you had been updating your boot kernel or initrd or something. I'm sure there are other edge cases. But this is still not the ideal way to shutdown a system. Don't rely on it.

Also, running 'sync' is likely useless in this situation (I say "likely useless" because I'm not 100% sure of my facts here and I don't feel like fact-checking). Running 'sync' before the 'dd' step will not make the image any more consistent because 'dd' does not simply bypass the kernel and talk directly to the hardware. 'dd' still goes through the Linux kernel. If 'dd' requests data from dirty blocks (updated data that has not by synced to drive) it does not ignore this fact. In other words, 'dd' will actually copy the dirty blocks even though they have not been synced to the disk yet. Note that I believe there are options to ask 'dd' to do this (bypass the kernel buffers and talk directly to the hardware), but this is not the default behavior.

1
  • There is an important differemce between a sudden power outage and dd'ing a live filesystem -a dd is not instant, so writes will occur which are untracked and can corrupt data. A dd of a snapshot of the data would be more similar (and a lot safer) then a dd of the live system.
    – davidgo
    Apr 21, 2023 at 9:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .