Site menu:

Xubuntu Backup and restore - The easy peasy way

 

There's no need to use programs like Ghost to create backups of your Ubuntu system (or any Linux system, for that matter).

My system is Xubuntu - and so directions are for Xubuntu,but this will work on any version of a Ubuntu/Debian Linux or any other flavour of linux for that mater.

Before you start backing up.

BTW My set-up is stripped down to the basics - no ooo, gimp, thunderbird , games, ect

 

HOW TO BACKUP (about 30mins)

First remove any usb/flash drives from your pc

Then open Filesystem on your desk top, this will bring up file manager (thunar)which shows the root system of your drive. in the window that shows your files right click and "open terminal here". This will open a terminal window.

Next become root with sudo su - enter you root password (the one you log into the desktop with) and press enter. You will notice that the command line changes to some thing with # at the end. before you became root it ended with $.
To ensure you are in the root directory type - cd /

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 /

Press enter and sit back and watch the screen fill with info that flashes past as the filesystem is being compressed into a file.

After a while (maybe quite a while depending on your install and computer)the command line will reapear.

At this point close the terminal by "x-ing" in file manager you will now see a file called backup.tgz this is your backup. You now need to copy this file to somewhere else - I use a 2G flash drive.

You can now play to your harts content and if you break something you can reinstall very eaisly.

 

HOW TO REINSTALL. (less than 15 mins)

Once you system refuses to work the way you want or to roll back to the perviously saved state you will need.
Your system's LiveCD and access to the backup file - on a flash drive will make it easy.

Reboot your pc using the LiveCD
Open the harddrive folder on the desktop, in the window that shows your install right click and "open terminal here". This will open a terminal window.
The comand line should read ubuntu@ubuntu$ /media/disk
Next become root with sudo su
you dont need a password on the livecd
Now type rm -rf *
This wipes all the files on the drive - which you will see disapearing in file manager.

Once this has finished plug in the flash drive and it will open in a new file manager
In the window that shows your files right click and "open terminal here". This will open a terminal window.
the comand line should read ubuntu@ubuntu$ /media/nameofdisk
Next become root with sudo su
You dont need a password on the livecd
Type cp *.tgz /media/disk
once done the command line will return.

In the ubuntu@ubuntu$ /media/disk terminal
type ls
and it should show backup.tgz in green.
now type, tar xvpfz backup.tgz

Once again the screen fill with info that flashes past as the filesystem is being decompressed from the backup file. After a while (quicker this time) the command line will reapear.

Then type these commands-
mkdir proc
mkdir lost+found
mkdir mnt
mkdir sys

Once done type reboot -n and press enter.

The computer will reboot, remove the disk and restart back into you saved desktop.

 

Now, lets explain this a little bit.

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

The 'tar' part is, obviously, the program we're going to use.

'cvpfz' are the options we give to tar, like 'create archive' (obviously),
'preserve permissions'(to keep the same permissions on everything the same), and 'gzip' to keep the size down.

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

Next comes the root of the directory we want to backup.

Since we want to backup everything; /

Now come the directories we want to exclude. We don't want to backup everything since some dirs 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. Also make sure you don't have anything mounted in /media (i.e. don't have any cd's or removable media mounted). Either that or exclude /media.

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