Most of you have probably used Windows before you started using Ubuntu. Undoubtedly at least once you had the need to backup and restore your system. For Windows you would need some costly software for which you would have to reboot your machine and boot into a special environment in which you could perform the backing-up/restoring (programs like Norton Ghost).
During that time you might have wondered why it wasn’t possible to just add the whole c:\ to a big zip-file. This is impossible because in Windows, there are lots of files you can’t copy or overwrite while they are being used, thus the need to boot into a different environment.

Well, I’m here to tell you that those things, just like rebooting, are Windows CrazyThings ™. There’s no need to use programs like Ghost to create backups of your Ubuntu system (or any Linux system, for that matter).


“What should I use to backup my system then?” might you ask. Easy; the same thing you use to backup/compress everything else; TAR. Unlike Windows, Linux doesn’t restrict root access to anything, so you can just throw every single file on a partition in a TAR file!

To do this, become root with

sudo su

and go to the root of your filesystem (I use root in my example, but you can go anywhere you want your backup to end up, including remote or removable drives.)

cd /

Now, below is the full command I would use to make a backup of my system:

tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys --exclude=/media /

Now, lets explain this a little bit.
The ‘tar’ part is, obviously, the program we’re going to use.

‘cvpfz’ are the options we give to tar
c – ‘create archive’
v – ‘verbose’
p – ‘preserve permissions’
f – ‘file (as opposed to stdin/stdout)’
z – ‘filter the archive through gzip’.

Next, the name the archive is going to get. backup.tgz in our example.

Now come the directories we want to exclude. We don’t want to backup everything since some directories aren’t very useful to include. Also make sure you don’t include the file itself, or else you’ll get weird results.
You might also not want to include the /mnt folder if you have other partitions mounted there or you’ll end up backing those up too. Lastly the /media directory is ignored as this directory hold any additional mounted devices such as CD-ROMS and additional hard drives.

Next comes the root of the directory we want to backup. Since we want to backup everything; /

That’s it! Hit enter (or return, whatever) and sit back and relax. This might take a while depending on how much data is stored on your hard drive.

Afterwards you’ll have a file called backup.tgz in the root of your file system, which is probably pretty large. Now you can burn it to DVD or move it to another machine, whatever you like!

Notice that you may use the Unix “split” command if the back up file you made is too big to fit on a single CDR/DVDR


At the end of the process you might get a message along the lines of ‘tar: Error exit delayed from previous errors’ or something similar, I have not been able to figure out where that comes from, however the backups i’ve made using this method have restored without a problem.

Alternatively, you can use Bzip2 to compress your backup. This means higher compression but slower speed. If compression is important to you, just substitute
the ‘z’ in the command with ‘j’, and give the backup the right extension.

That would make the command look like this:

tar cvpjf backup.tar.bz2 --exclude=/proc --exclude=/lost+found --exclude=/backup.tar.bz2 --exclude=/mnt --exclude=/sys --excluse=/media /


Warning: Please, be careful here. If you don’t understand what you are doing here you might end up overwriting stuff that is important to you, so please take care!

Well, we’ll just continue with our example from above; the file backup.tgz in the root of the partition.

Once again, open up a terminal window, make sure you are root, and that you are in the same directory as your backup.tgz file.

One of the beautiful things of Linux is that This’ll work even on a running system; no need to screw around with boot-cd’s or anything. Of course, if you’ve rendered your system unbootable you might have no choice but to use a live-cd, but the results are the same. You can even remove every single file of a Linux system while it is running with one command. I’m not giving you that command though!

Well, back on-topic.
This is the command that I would use:

tar xvpfz backup.tgz -C /

Or if you used bz2;

tar xvpfj backup.tar.bz2 -C /

WARNING: this will overwrite every single file on your partition with the one in the archive!

Just hit enter and watch the fireworks. Again, this might take a while. When it is done, you have a fully restored Ubuntu system! Just make sure that, before you do anything else, you re-create the directories you excluded:

mkdir proc
mkdir lost+found
mkdir mnt
mkdir sys
mkdir media


And when you reboot, everything should be the way it was when you made the backup!

Well that’s it! I hope it was helpful!
As always, any feedback is appreciated!