Just like any other operating system, it's very important to be able to back up and restore your Ubuntu files and installed software and settings. Backup Media: CDs, DVDs or USB? Or a Second Hard Disk Drive? The old way was to write files to CDs and DVDs but I'm not sure if many people do it that way anymore. Hard disks have increased in capacity and come down in price per GB. Files and file systems have grown and technology has progressed. Many people take more pictures than they use to and even make home movies now. Most people are saving more files than we used to and also large files. Burning them all to optical media would be time consuming. If you just want to make a backup of your regular files, then you'll probably need a spare hard disk drive or an external USB drive at least as large as the hard disk you have Ubuntu installed in. They're not expensive these days. One thing to be careful of is to make sure your external USB drive or other hard disk drive or whatever you're going to use is formatted with a good Gnu/Linux file system. That could be worth thinking about if you need file ownership and permissions to be preserved, which can be important for some kinds of files especially if your backup will include software files like bash scripts and python programs and so on. Security Reminder - even if you don't think you have anything private included in your backups, you probably do have a lot of personal and/or business information. You really should consider creating a fully encrypted file system using Linux Unified Key Setup, (LUKS for short) to store your backup files in. See the bottom of this page for more, (down). Regular user files KISS (Keep It Simlpe Stupid) - The simplest way to do things is often the best. That is, you just create an new empty directory in the other drive and then copy all of the contents of your entire /home/username directory into it. Documents, Pictures, Video, Downloads, Backups, whatever. This makes a plain ordinary simple backup of your regular files and it can be very convenient. If you make a mistake and delete a file or something silly you can easily just go browsing through your backup files and find the file you're looking for and copy it back again. That's better than having everything bundled up in some kind if a tar ball that only some special program can open and that you can't just fish through looking for just the one file or paragraph you need in a hurry. If you give the each new directory you are making backup copies of your files in after the year, month, and day, something like '2011-07-14_backup' and '2011-08-21_backup', the directories will automatically remain sorted for you in chronological sequence. If you have your own ideas about how they should be named, that's okay, you can always just use nautilus's 'View', 'Arrange Items by' menu to sort them any way you want, but I like to use this naming by date method as well. Most of the time I use a more descriptive word after the number than 'backup', I make frequent small backups of all kinds of things and I replace the word 'backup' with something more specific to help me locate things again later. Firefox If you want to be a little bit fancier, you can make a back up your firefox bookmarks and include that in your collection of backed up files as well. To make a backup of your firefox bookmarks, open firefox and click 'ctrl'+'shift'+'o', or click 'Bookmarks', 'Show all Bookmarks'. Whichever way you did it, you should end up with a window called 'Library', and near the top you should see an menu called 'Import and Backup'. When you click on your 'Import and Backup' menu, a drop-down box should offer you the options to make a Backup, Restore from a backup , or import HTML or restore HTML.
Obviously, restoring such a backup is simply the reverse process and shouldn't require any more explanation. Evolution If you use Evolution Email, you'll want to make a backup of your addressbook, calendar, mail, memos, and tasks. Open Evolution and go to the 'File' menu and click 'Backup Evolution Settings'. This will offer to create for you a file called something like 'evolution-backup.tar.gz', and you can edit the name if you need to and navigate to choose the diretory you want it saved to. Evolution will close to make the backup, and reopen again. Again, restoring such a backup is simply the reverse process and shouldn't require any more explanation. Other Softwares (Settings) Many other softwares we use have their user configurable settings stored in hidden files inside your /home/username directory. I use a program called 'Password Manager', which stores all my account details passwords in an encrypted file. Backing up my Password Manager is easy, I just open my /home/username directory and click 'View', 'Show Hidden Files'. A lot of files will then appear with file names beggining with a dot. The dot before the file name tells Linux not to display the files we don't need to see most of the time, and 'show hidden files' over-rides that rule. Now I just copy my .gpass directory and paste that into my backup files along with all the rest. To restore, I simply do the reverse, after my new operating system is installed, I just paste the backup copy of .gpass into my new /home/username directory. As soon as I install Password manager again and start the program for the first time it automatically detects the .gpass directory and asks for my master password to unlock the encrypted .gpass folder and loads all my accounts and passwords again. You may have other programs that also store their user settings in hidden files in your /home/username folder, so take a look around while you have 'show hidden files' enabled to see if there's anything else much in there you might want to backup in a similar way. Users settings for many Gnu/Linux programs can be backed up and restored in this way, but I can not promise it will work for all programs. You may need to consult your help menu or other documentation for your specific program to make sure. Backing Up Installed Software Software we install in Ubuntu generally comes in files with the .deb file name extension and they are normally stored in a directory called /var/apt/cache/archives. There are a lot of them, as you will see if you type the following into a terminal,
You can make a backup copy of these, but they're mostly only good for another Ubuntu installation that's the same architecture and the same release as the one you have. You should not attempt to use .deb files from an amd64 (dual core) Ubuntu in an i386 installation or vise-versa, or install .deb files from an older version of Ubuntu to a newer version. Including these .deb files in a backup can be useful as long as you reinstall and restore them fairly soon, like within a week or two, or within a month or so. It doesn't pay to store these .deb files for too long because they get superceded as new software updates are made on a regular basis. The reason why you may want to backup your .deb files and restore them again is only to save a few minutes of downloading and a small amount of internet bandwidth. If you don't care about wasting a some internet bandwidth you might be able to skip this whole idea. On the other hand, if you're on dialup of you live in a country where bandwidth is limited, it might be worthwhile backing up your .deb files. Some .deb files do take a lot of downloading. Some people, (like me), like to install a lot of fancy fonts and those take a lot of download time and bandwidth. They occupy some hard drive space too. Fonts are worth keeping and re-using. They don't go out of date and can be used in any Ubuntu or other Gnu/Linux OS. To back up your .deb files, simply navigate to /var/cache/apt/archives/ and copy and paste them to a folder along with the rest of your regular file backups. To restore them you will need a sudo command like this,
Then you will still need to install them in the regular way. Some people use the Ubuntu Software Center, others use Synaptic Package Manager and some use apt-get commands in terminal. No matter how you do it, the software can be re-installed but it won't need to be re-downloaded from the internet, it will be reinstalled from the .deb files in /var/cache/apt/archives. Links: Backup installed packages on ubuntu - ubuntugeek Create backup of all installed packages using APTonCD in Ubuntu - ubuntugeek about apt-get by ubuntu_demon --> A Concise apt-get / dpkg primer for new Debian users. |
| Here's another way to do it, (slightly more advanced) When you have an installed operating system with all of your favorite software added, you might want a list of the programs you installed so you can easily install the same ones again in case you ever need to re-install for some reason. This is only good for installing in the same version, not for upgrading to a newer version of Ubuntu. Installed .deb packages are stored in /var/cache/apt/archives, and you can make a backup of all the packages in /var/cache/apt/archives and copy it into another /var/cache/apt/archives in another installation of the same version of Ubuntu so you won't have to re-download the same packages again from the internet.
This command will output a list of all packages installed by default in a new installation to a text file and call it installedI.txt.
This command will output another list of all installed packages to a text file and call it installedII.txt.
Then,
|
| File Compression When you have a directory full of all the files you want included in a backup, you can easily make it into a compressed archive simply by right-clicking on the folder and clicking 'compress'. You have a range of choices for various grades or kinds of file compression in Ubuntu. The standards ones are .tar, (just an archive, no compression), tar.gz (some compression) or .tar.bz2 (takes longer and compresses the file to a smaller size). Decompressing is just the opposite. |
| Applications for Performing Backups and Restoring There are programs you can look for in Ubuntu Software Center which automate all of the tasks I have just described above, and more. It would be investigating and trying a few of them out to decide if there's one that suits you. Just type a word like 'backup' in the search bar of your Ubuntu Software Center and take your pick. |
|
Whole Partition Back-up and Restore
Sometimes we want to make a backup of an entire operating system, complete with added software and settings. Copy and Paste the whole partition with GParted This was the original method I had here, I'll still keep it here for a while in case it's useful to anyone. This was my favorite method for a long time. Backing up with GParted It's easy to resize your Ubuntu operating system to as small as possible and just copy and paste the whole thing to an area of spare disk space. That will be a fast and easy way to back up everything, including added software and system settings, the whole lot. It only takes me about ten minutes to copy and ten minutes to restore. Most people would want to remove some of their stored data first in order to shrink the partition to a very small size. Restoring with GParted You just copy the back-up copy of the partition you made earlier and paste it. Then you re-size it to the size you want again. Be sure to delete the old partition first, though, to make sure you get the same partition numbers as you had before. If you get different partition numbers you will need to re-install GRUB. Complete Back-up Using File Compression Sometimes, using file compression to make one big tar file is the best thing to do. You can get a lot of work done a faster that way sometimes, and squeeze more onto your back-up media too. Here's a link to a way to make a more complete back-up and restore job, using file compression. Here is another link, Howto: Backup and restore your system! - Heliode - Ubuntu Web Forums. Partimage Partition Back-up It would be best to look at aysiu's tutorial, Use PartImage NOTE: Use your spacebar on your keyboard to move the cursor in Partimage. GParted LiveCD and Parted Magic both have Partimage in them. To start Partimage in GParted LiveCD just open a terminal and type: partimage Following are more links, Partimage Home Page, http://www.partimage.org/Main_Page Partimage Manual, http://www.partimage.org/Partimage-manual_Usage GParted LiveCD also has Clonezilla added to it by LarryT as well. Partimage is safer for most people to use than the dd command. dd command Another way to do things is to copy an entire partition to a file in another hard disk. Possibly the partition can contain an entire working operating system. You might find it advantageous to remove most of the users files from the operating system first and back those up seperately, and resize the partition as small as possible with GParted before creating your backup. This will make it easier to restore later. backup
restore
Notes:
Note: Windows 7 and Vista users, you should consider also making a backup of your original hard disk's MBR. See MBR backup and restore. Also, check your EULA. CAUTION: Be very careful with the 'dd' command, if you accidentally run it backwards and copy the damaged operating system to the good one you will destroy your good copy of the operating system! Please double check and then check again before running the command. |
|
Entire Hard Disk
Clonezilla - Clonezilla is safer for most people to use than the dd command. Link: Clonezilla Imaging By Raymond Siudak.pdf dd command Copy an entire hard disk to another hard disk,
This command is useful when you want to replace a hard disk with a larger one, or if a hard disk is on it's way out but still readable, and you want to copy the contents to a new hard disk in time before the old one deteriorates too much further. You would need to issue this command from a Linux operating system running in another media, such as a Live CD or USB operating system, or an operating system installed in another different hard disk. CAUTION: Be very careful with the 'dd' command, if you accidentally run it backwards and copy the blank disc to the one with the data you will erase all your data! Please double check and then check again before running the command. |
Security Reminder It's always recommended to keep making regular backups to some other media than the hard disk your operating system is running in. Naturally, if you store your backups anywhere where others can get ahold of them, you potentially have a huge security loophole. In case you haven't thought of it already, if could be a good idea to keep your backup media in a locked box of some kind or even in a safe if the backups might contain any kind of sensitive data. If you don't want to do that and security is any concern, (and that would mean almost everyone), it's easy to make an encypted LUKS file system in a partition for storing your backup files in. Make a Linux Unified Key Setup Encrypted File System For Backup Storage WARNING: If wrongly applied, some of the commands shown below here can be dangerous to your files and systems. If a person following this how-to makes a mistake and types a wrong partition number they can lose data and/or an operating system.
2. You will need to install the necessary software,
3. Run this command,
4. This command is just to take a look at which partitions are which, you could use GParted to take a look if you prefer,
5. Be extremely careful with this command and make sure you use the correct /dev/sdx,y number the partition is that you want to encrypt, this will set the password and write the LUKS header to the first sector of the partition !!!
Note: Later on it might be a good idea to create a dd backup of the first two sectors of this partition as this now contains unique information that can be vital to the recovery of your data in the event that something should go badly wrong in the future. (unless you make another encrypted copy of the same backups). 6. This is to unlock the partition so we can work on it,
7. Create a new device called /dev/mapper,
8. Create the encrypted file system,
9. Make a mount point,
10. Relax the file permissions on the mount point so you can write to the new partition as a regular user,
11. Mount the encrypted file system for the first time,
Note: I don't think it's a good idea to trust any important data to this file system just yet, you could copy a few unimportant test files to it first if you like. Wait until you have rebooted and used the partition a few times before adding your serious backups to it. 12. Unmounting it afterwards,
After the first time, and after a reboot, your operating system will start listing the encrypted partition in your places menu automatically and you can just click on the icon for it and it will be mounted in /media. Links: Cryptsetup - LUKS Encrypt a partition with Dm-crypt and Linux Unified Key Setup - Linux Instruction HowTo: Setup and Benchmark Encrypted Partitions in Ubuntu - www.fsckin.com Tip: You might find it worthwhile to make two (duplicate) encrypted LUKS file systems in different hard disks since if anything goes wrong, file encryption can make recovery quite a bit more complicated. Tip: File system encryption doesn't give you any protection against network based intrusions. Ubuntu is secure by default and does not come with any open ports. Most people have nothing to worry about. If you have installed programs in Ubuntu that open networking ports then it is possible for somebody to see your encrypted files whenever your encrypted file system is mounted. You should use File Ownership and Permissions in addition to file encryption if you will have guests logged into your computer via any network connection. Tip: Use only SSH (Secure Shell) Networking between your computers, with SSH, data is encrypted while it is enroute between computers. See this website's SSH Network Page. Whatever you decide to do, just make sure you remember to think about security when you think about keeping backups of your files. |