Backing Up Your Files on Ubuntu Linux

The reality of having a new Ubuntu release every 6 months means you either upgrade your distro and deal with the inevitable bugs or you wipe your system and install a fresh copy from scratch. Before you wipe your system you are going to want to back up any files you have on your drive. This can be done with a simple command.

First switch to root:

sudo su

Then run the tar command:

tar cvpzf /backup.tgz /home

Running the above command will create an archive file in the root folder of all of the files in your home directory including all the settings stored in the hidden folders. Be careful though, if you have a lot of large files in your home directory this archive is going to be quite large. I usually manually backup any ISOs or video files before creating the archive. Also remember to empty your trash or the files in there will be backed up too. I usually just use this command to back up any documents and pictures I have. The great thing is this will backup your Firefox bookmarks and everything.

Now, I also want to save a few configuration files in my backup so I don’t have to recreate them on the new system. I’m talking about my xorg.conf, fstab, and sources.list files. It is easy enough to add these files to the archive, just tack the path and filename onto the end of the command and they will be included.

tar cvpzf /backup-oct-2007.tgz /home /etc/fstab /etc/X11/xorg.conf /etc/apt/sources.list

Now just copy this backup file onto a thumb drive or file server and you are good to reformat your drive and install your fresh copy of the latest Ubuntu. Once installed I just open the archive and extract any files I want to keep then turf the archive.

Leave a Reply