I am familiar with using rsync to back up various files from my system but what is the best way to completely restore a machine.

What I have tried in the past is:

Do a basic format/reinstall from the Fedora install disks

Make sure networking is enabled

Copy everything from rsync backup over the top of the newly installed system

This way sort of works but I do not think every package that was installed works 100% afterwards.

I want to be able to restore my system with the minimum amount of effort and everything work the same as at the moment the backup was taken. Also if possible install to other machines and essentailly have two machines with the same packages and data.

I have done this several times and has the advantage of using standard linux CLI commands.I use rsnapshot, a perl script around rsync to make backups to a central server. Then rsync the whole thing back after booting from sysrescuecd and dd'ing the partitions table. BTW, "partprobe" will re-read the partition table
–
Mark PorterJun 4 '09 at 19:06

OK, this may be seen as a vile hack but since you can have the kernel reread the partition table by issuing a sysctl() like fdisk does, you might just as well have fdisk - which unlike partprobe is always there in my experience - do it: fdisk /dev/yourdisk <<EOF w EOF
–
Bernd HaugJun 4 '09 at 20:44

Thanks for everyones suggestions, I knew there must be a better solution out there. Will try these suggestions and see what works best for me.
–
Simon FosterJun 4 '09 at 20:50

I never clone systems entirely. You never know what may change, and your system cloned image is already out of the date the moment one change occurs. The best way to do it is to establish a procedure that lets you produce functionally identical systems. One possibility is something like Kickstart, or AutoYaST or similar tools. Keep good backups of your configuration, and ideally use a configuration management system such as Bcfg2, Puppet, or CFEngine to configure everything instead of doing it by hand. Then when you need to create a new system that's similar to another one you have, or recreate an existing system, it's a simple and well-defined procedure.

Grab a copy of system recovery cd, and after your initial minimal install, boot from it, mount and chroot into your disk, and then do the rsync. After it's finished you may need to run update-grub to get it booting from the correct boot device and kernel.

Try clonezilla live cd. You can boot into a live session and image your machine without having to install anything. You then have the option to store the copy of the image on a network share or remote machine and so on.

If it's the exact same machine, I would just use dd to create a disk image, then reimage it as necessary (possibly changing some configurations afterwards if appropriate).

If you're switching hardware, I've had some success creating a tarball or complete rsync backup of the file system root. I'm not sure why you'd need a complete install first - as long as you take a full backup, the base Fedora install shouldn't be a prerequisite.

There are two primary recommended ways to go about this, and a third if you are purely trying to build a development environment.

Imaging

If the hardware that you will be restoring TO will be the same, or similar enough, use a disk imaging tool to make a copy of the entire hard drive or array. When you wish to restore, simply re-image the machines in question with this image. If you image to multiple machines, be aware that you will need to update any machine-specific settings on the other devices (hostname, static IP address, etc...) such that they do not conflict with one another.

To do the actual imaging, I would recommend any tool or product that can clone hard drives.

Configuration/Home Directory backups

On your primary machine, regularly back up (with whatever method you like) whichever of the following directories (or others) you require:

When restoring, re-install the OS on the machines in question, and then copy each of these (or the relevant files only) to its proper location.

Virtual Machines with snapshots

Create a virtual machine in VMWare (or whatever else you prefer). When it is configured as you wish it to be, create a snapshot. This snapshot can then easily be restored to any number of new or existing virtual machines.

In general, you should only back up data and configurations (however you define these). The OS and software can trivially be rebuilt at any time: only your own content is valuable. If this setup is for development, and you need to ensure an identical environment (as opposed to simply getting things working again), then snapshots in a virtual machine are really your best bet.

Imaging is the brute force solution. If you can, just back up your data, and don't worry about the OS itself. Trying to restore it entirely is asking for trouble.

If you can clarify what your final intent is here, I can provide a more detailed solution.

Since you say "hardware will be different", SystemImager can come very handy.

It is just a bunch of wrapper scripts around PXE and Rsync.
Therefore the "backup" that it creates is just a complete directory structure of your backed-up Linux server. You can "cd" into this dir and change stuff around as you feed. (SystemImager manages changing Network settings on its own when you push the image out.)

You can chroot into your backed up server and run yum or apt to install software before you push the image out.

Edit: You can take a look at the SI script that creates partitions/logical volumes and modify it according to the disk size of the target machines. You can also add/remove kernel modules.

The safest way is to clone the whole
disks or at least the relevant
partitions and restore them using a
Live CD.

Another more space efficient method
is to use dump (xfsdump for XFS), but
in this case you'll have to recreate
(format) the partitions by hand.
Don't forget to create them with the
same parameters, especially UUID and
LABEL.

You can also use tar with the --xattrs
parameter to save each file's extended attributes.