I am looking for a method to backup a whole disk in case something is screwed up...

I don't even know what to install on some special devices of the server, and every time it is not the same.

Would cp -a for the / directory work?
Is there any program that can copy all the data of the hard disk? (like an image of the hard disk).

I know that this exists at least for Windows..

The hard disk is on a RAID 1 though....

  • 1
    Yes, you can back up the whole hard disk, and there are many ways of doing this. What media are you backing up to? How often are you doing backups? How fast do you need recovery to be? Apr 10, 2011 at 18:56

5 Answers 5


As already noted, there are a lot of options and which one is the best depends on your requirements.

Since your systems is on RAID1, you can simply replace one disk and let your mirror rebuild itself. The removed disk can be used as a backup copy.

In the past, for full system backups, I have used Ghost4Linux (aka G4L) and Mondo/Mindi. The former can save a partition image locally or remotely and the later can create bootable restore (+rescue) CDs or DVDs. Both have a ncurses gui, no need for command line usage.

But many times, I just copy the whole system. I mostly use rsync but here are some options that I think it's what you're looking for.

Let's assume you have two partitions, / and /var and you want a complete backup. All commands require root privileges.

mkdir /mnt/orig
mount / /mnt/orig -o bind
mount /var /mnt/orig/var -o bind

This will create a new mount point for rootfs that you can now copy without worrying for other mounted filesystems like /proc or /sys or network shares.

Let's assume you have a second disk formatted with an appropriate filesystem and mounted under /mnt/backup (or an NFS on the same mountpoint). It is advised that some services should stop running, for example the mysql service or mail server, to ensure integrity of the replicated data.

Each of the following commands should suffice.

cp -a /mnt/orig/* /mnt/backup/
rsync -a /mnt/orig/ /mnt/backup/
tar -C /mnt/orig -cf - ./ | tar -C /mnt/backup -xpf -

The last one is kind of overkill though. tar and rsync provide a --exclude parameter for skipping files based on pattern matching, e.g. --exclude=\*.log --exclude=var/tmp. The above commands do not use compression and you will have an exact replica of your system. You can also install grub and make the backup disk bootable.

If you have limited space on your backup device or a not compatible filesystem (NTFS) or it is a CIFS mounted share, you can create a compressed tar archive.

tar -C /mnt/orig -zcf /mnt/backup/mybackup_$(date -I).tar.gz ./

or create a squashfs image which you can later loop mount and browse its contents like a normal filesystem.

mksquashfs /mnt/orig/ /mnt/backup/mybackup.squashfs
mkdir /mnt/squash
mount /mnt/backup/mybackup.squashfs /mnt/squash -o loop

Also, getting a remote backup with ssh and tar or rsync. rsync requires root access to the remote server in order to preserve ownerships, permissions, device files etc. --numeric-ids is necessary for not mixing ownerships with the remote system's users.

tar -C /mnt/orig -zcf - ./ | ssh user@server 'cat -> mybackup_$(date -I).tgz'
rsync -aP -e ssh --numeric-ids /mnt/orig/ root@server:/path/to/backup/

In most cases, a full restore will require booting with another system, preferably a Live CD, then creating/rearranging your partition scheme, coping/extracting your data back and at the installing the boot loader again.

  • Since your systems is on RAID1, you can simply replace one disk and let your mirror rebuild itself. The removed disk can be used as a backup copy. RAID is not a backup. Aug 27, 2018 at 19:40

The native way of doing this is to create an LVM layer between your partitions and the disk. LVM has the capability to create snapshots which are basically instant point-in-time instances of the disk. The reason for this instead of just dd'ing the disk directly is that the contents of the disk may change while the dd is in progress. An LVM snapshot will not change once its created. Then after your backup is complete, destroy the snapshot.

So the layered topology would look something like:

You could also put LVM on top of each partition if you wanted to back up just a single partition. Either works

  • Abstractions galore! ...interesting... (and all sired by the humble punchcard :) ... +1 for explaining where LVM fits into the general picture
    – Peter.O
    Apr 11, 2011 at 11:22

dd on the device is a way to clone a hard disk.

  • 1
    So is cat. There's nothing magical about dd, the magic is in /dev/sd*. And no, dd isn't faster. Apr 10, 2011 at 19:35
  • It is a solution but the image is too large..That means that it wont work at another disk... If i use cp for the files and dd for MBR would that work ?
    – GorillaApe
    Apr 10, 2011 at 20:06

How about using Clonezilla http://clonezilla.org/ for this? Clonezilla LiveCD is very easy to use.


PING (Partimage Is Not Ghost) live disk that backs up images of the partition, although it will cause downtime while you make the image

You must log in to answer this question.

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