FOSUGMain Page | About | Help | FAQ | Special pages | Log in

Printable version | Disclaimers | Privacy policy

Tar Howto

From FOSUG

As a new user, it's possible that you'll break things in linux and not even know how, when, or why it happened. All you'll know, is that you log into your computer one day, and it doesn't work.

However, after a few weeks or months on linux you'll probably have set things up the way you like, such as a certain desktop picture, your email, and browser settings, so the idea of starting all over makes you heartsick. If you jumped in with both feet, you may even have data that you've created that you'll want to protect. So, this tutorial is a nice way to backup everything in your home directory in one package so that you can burn it to a disk and save it for that rainy day.

Linux comes with tar a handy archiving utility, preloaded. It's like WinZip on steroids, because it's much more handy, and learning how to use it can prepare you for lots of other linux chores.

Before you begin, make yourself a little text file with the names of all of the programs you've installed and save it in a place you'll easily find it, with an obvious name.

For this tutorial, we'll use the command line, and I'm working in Ubuntu Linux. If you're working in another distro, your root login method may differ.


Open terminal > Log in as root:

sudo -i

Move to “home” directory:

cd /home

Create tar of personal directory named 'yourfilename.tar.gz':

Explanation:

tar -cvjf yourfilename.tar.gz yourloginname --exclude=yourfilename.tar.gz

c=create, v=verbose, j=compression f=file

--exclude=yourfilename.tar.gz = "Don't include yourfilename.tar.gz in the backup"

Once it's done, move tarred file to desktop:

mv yourfilename.tar.gz /home/yourloginname/Desktop

Or, you can run both commands one right after the other in one command:

tar -cvjf yourfilename.tar.gz yourloginname --exclude=yourfilename.tar.gz && mv yourfilename.tar.gz /home/yourloginname/Desktop

Exit root mode:

exit

So, now your whole home directory is encapsulated, compressed and ready for you to offload to a external drive or burn to a CD/DVD. Save your little text file of installed program names as a separate file, but saved onto your CD/DVD. In your Rescue Kit, also keep a reasonably fresh bootable CD/DVD of your linux distro - Ubuntu is assumed, but YMMV.

Later:

Now the evil day has come. You've tanked your system, can't figure out what you did or how you did it, and it looks like it will be easier to just start over than to unravel the mess. Grab your Rescue Kit. Pop the bootable linux distro into the drive, load it up, and reinstall the OS. Once you are back up, do all your updates, and install the printer. Now, get your CD/DVD backup of your home directory. Load that in the drive and open the text file of all of the programs you had loaded on your computer, previously. You can load them all at one time using Synaptic or drop to a command line and load them using the following method:

sudo apt-get install program1 program2 program3

and so on.

Now, you've got your OS back up and breathing, and all of the programs loaded that you had before. Now it's time to put all your data and settings back where they belong, Copy your file to the Desktop for easy access before you begin. Then:

Open terminal > Log in as root:

sudo -i

Move to the home directory

cd /home

Move tarred file to /home directory:

mv /home/yourloginname/Desktop/yourloginname.tar.gz /home

untar yourloginname.tar.gz into the home directory:

tar -xvjf yourloginname.tar.gz

x=extract, v=verbose, j=uncompress, f=file

exit as root:

exit

exit terminal:

exit

Log out of GUI Desktop and restart to see changes. You should now have everything the way it was before The Great Disaster, and you can continue on your happy little penguin way.

Remember to create a tar of your home directory often, so that you won't have far to fall if you need to rebuild. Also remember to download and burn a bootable copy of your OS often - if you're using Ubuntu, at least twice a year.

Retrieved from "http://www.fosug.org/fosug/index.php/Tar_Howto"

This page has been accessed 184 times. This page was last modified 23:35, 1 June 2009. Content is available under GNU Free Documentation License 1.2.


Find

Browse
Home
About Fosug
Announcements
Group Photos
Schedules
IRC & Chat
Mailing List
Library/Resources
Previous Meetings
HowTo/Videos
Articles
Links
My Account
Edit
View source
Editing help