How to create backup

Tarun Mall         1 comment

pHello friends :)

I have been testing kubuntu natty beta versions and faced a lot of crashes. Reinstalling from live-cd is always an option but since I have very slow internet connection reinstalling all the applications normally takes whole night. That's when I started looking for ways to backup the root partition. You can use this method to backup any folder or partition or anything. I'll mention here using root partition.

so lets start :)
On googling "create backup linux" you'll find many applications and post all around the place, but there are reasons of not using them. Two most important of them are:
1. If your system crashed and you are not able to access internet then you wont be able to get that application to call for a restore.
2. And why use an application when you can do it without it ;)

Lets begin.

Creating Backup:

First for backing up root partition you need to have root access, this might not be necessary when creating backups of other folder.

sudo su

cd /

Now here is the full command for creating the backup:

tar cvpzf backup.tar.gz --exclude=/proc --exclude=/lost+found --exclude=/dev --exclude=/backup.tar.gz /

lets explain this command a bit.

tar is the tool we are using to create the backup archive.

p->preserve permissions
z->use gzip (you can replace z with j if you want to use bzip2)

Then comes the name of the archive you want, since there is no meaning of extensions in linux you can keep any name. I use extensions to remind me how to use a particular file.

Then comes the directories you want to exclude.
You can simply add --exclude= you want to exclude.

Lets pay a bit attention to this.
/proc and /dev are virtual directories, they actually don't exists but they get generated on system startup.
In case if your home folder is on some other partition you don't want to back it up. So you can include --exclude=/home
If there are other partitions on your system and lets say they are mounted in /media/mount-point and in case you don't want to back them up you can include --exclude=/mount

And finally what is to be included in the archive, here it is '/'. As we all know mount point or root folder is / in the partition so in order to back whole root partition you simply use /

Press return and sit back for a while :) this may take some time.
When it is finished you can see backup.tar.gz/backup.tar.bz2 file in root folder. You can either burn them to cd or keep them anywhere safe. :)


WARNING!!!-> PLEASE PLEASE PLEASE be careful here, if you don't know what you are doing here, you might end up overwriting stuff that is important to you.

Lets begin
Well sometimes you might want to restore simply because you want to restore ;) but here we'll consider the worst condition.

Lets say that your system crashed, grub crushed and peeled off and now you have no choice but just to boot from the live-cd :)

So what.... boot from live-cd

Start kubuntu/ubuntu/edubuntu or any distro you are using.
Let me summarise what we are about to do, if you don't understand it re-read it zillion times but don't move forward until you completely understand it.


We'll first format one partition, mount it somewhere so that we can get access to that partition and then we'll untar our backup tarball here.


For formatting use Gparted, Partition manager or anything with which you feel comfortable.
Once the drive is formatted we have to mount it somewhere.
I am mounting my /dev/sda1 to /mnt

sudo mount /dev/sda1 /mnt

mounting can be performed only by root privileges.

Open terminal browse to the location of backup tarball (if it is in some other partition which is not mounted you have to mount it too DO NOT MOUNT IT ON /mnt, mount it somewhere else. I am leaving this upon you guys :) )
Well here is the command for untarring the tarball.

tar xvpzf backup.tar.gz -C /mnt/

most of the part is explained except
if you created a bzip archvie replace z by j

Now your root partition is ready :)
Well technically since your backup included grub there is no need of installing grub in it :) but still if you created a backup few days ago and you installed few new operating systems after that you need to reinstall grub. You can refer to my other post into this blog of how to get grub from live-cd :)


Published by Tarun Mall

A blogger by passion.You can find me tucked in my bed and blogging on weekends when not roaming around. Besides blogging, I love music and you can find my songs on my fb page:PraveenUnplugged
Follow on Youtube : Videos On Latest Happenings |ThingsToKnow
Follow us Talend In Action

1 comment:

  1. In case of any questions, you can either comment here or can find us in #kubuntu-devel on IRC
    our IRC nick's are c2tarun and makis.
    Feel free to poke :)


© 2015 Techie's House. Designed by Bloggertheme9