Illustrated Dual Boot  Site
Back Up & Restore
Logo.png

Edited Thursday, March 25 2010  Document made with KompoZer
 
This web-page is part of a larger site giving examples of how to install Windows+Ubuntu Linux operating systems 'dual boot' in a computer.  Illustrated Dual Boot HomePage

In a nutshell
Backing up and restoring is very simple in Ubuntu, at least for me, the way I like to do it.

Back up

Basically, all you need to do is copy everything out of your /home/username directory, making sure you include all those hidden files. With the home/username folder open, look in the 'View' menu, and click 'Show Hidden Files'. The hidden files are the ones with a . in front of the file name.
Remember to export your Firefox bookmarks if you can, I'll explain how to do that further down the page.
If you will be restoring to the same version of Ubuntu, you might also want your software packages from /var/cache/apt/archives. If you have any configuration files you want to save like specially modified /etc/apt/sources.list which gets updates from your own ISP's FreeZone mirror site, you might want to include that too.

You should make regular backups to some other media such as a different hard disk or USB drive, or to a DVD or CD-ROM.

Restore
All you need to do is copy the files you want into your new /home/username folder. It's pretty simple really. The files you copy into your new installation include your regular documents, music, pictures and so on.
After that there may be a few apps that you may use which have their settings stored in hidden files (with a . before the filename). These apps vary from user to user, according to what programs different people use. For me the .gpass folder is important, because that contains all my passwords for Password Manager.
After that there is evolution email, addressbook, calendar, memos and tasks, which are explained in this web page, and Firefox bookmarks. Firefox likes us to use it's 'import' and 'export' features, and evolution tasks might be starting to get that way too.
Finally, if you have software packages to restore you will need to use sudo commands to restore your collection of .deb files to /var/cache/apt/archives and special customized /etc/apt/sources.list.

There could be a few things I missed, but those are the main ones for me. I imagine everyone will be different, but that should give most people a few ideas to get started with.

Page Index
Small Scale Back- ups and Restoring

MBR backup and restore. - for paranoid Windows users mainly

The cp command. - how to back up and restore individual files


Normal Backup and Restore

Drag and Drop method of backing up.

Drag and Drop Restoring. - for normal files

Evolution Restoring (drag and drop  method)

Firefox Bookmarks  (Firefox Method)

File Compression - create or extract an archive


Using the Terminal

Evolution Back-ups, Terminal commands method.

Evolution Restoring, with Terminal commands

Make a backup script to run your backup commands automatically

Configure 'crontab' to run your backup script regularly at the times you set

Make a restore script

Back-up and Restore Added Software

tar   -nothing here yet - to be added

rsync  -nothing here yet - to be added


Whole Partition Back-up and Restore

Complete Back-up Using File Compression

GParted Partition Back-up.

dd command - partition


Entire Hard Disk

dd command - entire hard disc


Security Reminder

Backup Security 


TIP:  backup naming convention
I think it's a good idea to name backup files by beginning with a number representing the date, but backwards. The first two digits represent the year, the next two represent the month and the last two digits are for the day the backup was made.
After the date, I type a regular name describing what the file is.

For example, '080525MBR.img' would mean a MBR image made on the 25th of May in 2008.

The reason I like to type the date in backwards is just so they'll appear in chronological sequence in whatever directory I store them in. I find that very convenient.



Small Scale Back- ups and Restoring

MBR Backup and Restore
If you want to, you can make a back up of your hard disk's MBR with a Linux Live CD such as a ubuntu 'desktop' Live/Install CD before you begin your Linux installation.
This backup is for easily restoring your old boot loader if you make a mistake during the installation.

This MBR backup may be useful to Windows users because it will include your MBR's 'disk signature', which is important for booting Windows 7 and Windows Vista.
No Linux installation will overwrite the 'disk signature' in your MBR, but if you use a partition editor to set a new disk label, (format your hard disk), then your MBR will have a new 'disk signature'.

You can copy the MBR backup file to any media you like for storage.
 In this example I used a USB disk. You may use a floppy disk or a CD-ROM just as easily.
 
Create the MBR backup with a dd command
  1. Boot your Live CD. (Ubuntu Desktop in this example).
  2. Open a terminal (Applications, Accessories, Terminal)
  3. Code:
sudo dd if=/dev/sda of=/home/ubuntu/080525MBR.img bs=446 count=1
Where:  ubuntu is your username (it is the default username for the live CD),
Where:  your hard disk is seen as 'sda', by Linux, feel free to replace the 'a' with a 'b' or 'c' and so on if it's the second or third hard or more hard disk's MBR you're copying.
Where: '080525MBR.img' will be your name for your MBR backup file, you can make up your own file name here, anything you like.
quote:
  1+0 records in
 1+0 records out
 446 bytes copied,  4.3e-05 seconds, 10.4 MB/s

Copy the MBR backup to USB disk:
  1. Plug in USB flash memory stick
  2. Open /home/ubuntu directory, locate file named 080525MBR.img
  3. Open your USB drive, drag and drop 080525MBR.img there somewhere.
  4. Carry on with your Ubuntu Install.
Warning:
Some web pages recommend that you should make a backup copy of the entire 512 bytes of your MBR, including the partition table and 55 aa signature.

That may be useful for some purposes, but be sure you destroy that copy of your MBR if you decide to re-partition your disk later. If you accidentally restore your MBR backup with an out of date partition table, it might not match the filesystems you have currently on your hard disk. It may cause some of your partitions to be unreadable.  
You will need to use TestDisk to write yourself a new partition table - TestDisk Page.

Most people only need a backup copy of the bootloader code area, including the MBR's 'disk signature'. For that we only need the first 466 bytes of the MBR, so it will not include the partition table. That is much safer. That is what I do, and what is shown here. 

Restore command:
  1. You will need to copy your MBR backup file 080525MBR.img from your USB device to the /home/ubuntu folder in your Live CD for this restore command to work as it is, otherwise, you will need alter your command with the correct file path for the file in the USB.
code:
sudo dd if=/home/ubuntu/080525MBR.img of=/dev/sda bs=446 count=1
Where:  ubuntu is your username (it is the default username for the live CD),
Where:  your hard disk is seen as 'sda', by Linux, feel free to replace the 's' with an 'h' if appropriate, or maybe the 'a' with a 'b' or 'c' and so on if it's the second or third hard or more hard disk's MBR you're copying.
Where: 080525MBR.img is the name of your MBR backup file.

Here's a link to a website with more dd commands, Learn the DD command - LinuxQuestions.org


The cp Command
Every time we need to edit some important configuration file in Ubuntu we always make sure there is a back-up copy of the file first.

Any good how-to that you may be using will always ask you to use the cp command to make a backup or your original configuration file(s) before you modify the file(s).
No-one seems to bother to explain to newcomers what they need to do to actually restore the file if they need to. 
 
Lets try this out on a regular file just to see how it works, okay? 
Now say I am working on a text file called '2009_diary'.
Make one yourself in your own computer and try this.
Type a few lines of text into it for testing purposes if you like.

I made a back-up of the file by typing this code in 'terminal' (if '2009_diary' is a file located in my /home/herman directory).
code:
cp 2009_diary 2009_diary.bak
This will make a back-up of my '2009_diary' file and name it '2009_diary.bak'.
 
The same thing should work for you too, try it.
 
Later, I make a lot of alterations to a story in my '2009_diary' file, but then I decide they are no good and I want to go back to my original way of telling the story.
To restore my '2009_diary', I can  simply  open up a 'terminal' again, and type in pretty much the opposite command of the one I typed when I made the back-up of the file,
code:
cp 2009_diary.bak 2009_diary 
This will restore my '2009_diary' file to the way it was when I made the back-up.
Test this out yourself with your own '2009_diary' file, alter the text and then restore the original back-up copy and check to see what happens. It's actually a pretty nifty little trick. Linux is wonderful!

TIP:
Meld Diff Viewer is a really cool application for comparing the differences between two files. I highly recommend Meld Diff Viewer, it's great!
Meld Diff Viewer can be installed from 'Applictions'--'Add/Remove Programs' in Ubuntu, or sudo apt-get install meld

 
The same commands are used for backing up and restoring real configuration files, but you probably need to insert the word 'sudo' before the commands.
For example, you might have read the 'GRUB page' of this website, and made a back-up of GRUB's menu.lst file before editing it. The command used for that was:
code:
sudo cp /boot/grub/menu.lst /boot/grub/menu.lst_backup

Now if we are not happy with the alterations we made to the /boot/grub/menu/lst file, we can easily restore the old one by typing the following code into our terminals:
code:
   sudo cp  /boot/grub/menu.lst_backup /boot/grub/menu.lst

...and that is how to perform small scale back-ups and restore jobs in Ubuntu.

 There is one possible (major) problem to be aware of when you are new to this.
Imagine you followed one how-to and back up some text file like grub's menu.lst, and then you modify it.
Later, you follow another how-to and make a new back-up and then make more modifications to the same file. The second back-up will overwrite your first back-up so you will lose the original copy of that file.
Then if you later regret something you did when you edited the file the first time you might not be able to get your computer back to its original state easily.
Every user should think about this and decide what rules they want to make for themselves in regards to this type of situation. Maybe you should get in the habit of making an extra copy of the backup file and store it out of the way somewhere like in a special 'Backups' directory you might make for yourself. Alternatively, you might make it a rule that you only make a back-up copy of the original file once, and from then on always check for the presence of a back-up file before editing the file. For example, use the 'ls' command to have a look around and see what's there first.

code:
ls /boot/grub/

If there is already a menu.lst_backup in existence we may not want to make a new backup and overwrite the original backup. In those circumstances we might just want to skip that step in the how-to we are following.

  

 

Normal Back- up and Restore 
 
Drag and Drop Method for making backups
  1. Open your home (username) folder
  2. Open your backup media, (USB disk or CD Maker progam or whatever)
  3. Make a new folder in your backup media and name it something like '090624.backup' (2009, June 24)  or whatever you want to call it.
  4. copy and paste or drag and drop all of your other regular folders and files into it that you want to save.
  5. In your /home/username folder, go to the 'view' menu and click 'show hidden files'.
  6. make sure you copy all of your hidden files to your backup folder.
  7. Go find all the .deb files in /var/cache/apt/archives and them into your backup folder
  8. Also remember to include a copy of any special customized configuration files such as your /etc/apt/sources.list if you had a special one.
  9. Export Firefox Bookmarks
     Start your firefox web browser. Click 'Bookmarks', then 'Manage Bookmarks', then on the 'File Menu' of the 'Bookmarks Manager' window, click 'export'. Use the Firefox 'export wizard' to export a file for you to include in your backup. 
    
Drag and Drop Method for restoring
(General data)
When it's time to restore, just find what you want in your storage media and copy it back to your home (username) folder where it came from.
  1. In your /home/username directory, click 'View', and 'Show Hidden Files' again.
  2. Open .evolution in your new /home/username folder
  3. (Evolution needs to be started for the first time and set up before there will be a .evolution directory to open)
  4. In your backup media, click 'View', and 'Show Hidden Files'.
  5. Open .evolution in your backup media
  6. Drag and drop the .evolution addressbook,calendar,mail,memos and tasks folders into the new .evolution directory. The new file will overwrite the old one. so you'll see a sign like the one below. 
  7. fig1bkp
  8. fig 1 bkp You'll see a window similar to this. Choose 'Replace'.
  9. Drag and drop the hidden files for programs you recognize - many programs store their settings in hidden files in the /home/username folder. We all know our own favorite programs. I prefer to omit any hidden files I don't recognize and only restore the ones I will need, especially if I'm going to a newer version of Ubuntu. I'm worried in case there are updates in the software. I don't want to overwrite any new improvements with old files by accident or carelessness. For me, my .gpass folder is the most important, that contains all my passwords.
  10. Import Firefox Bookmarks File
    Copy and past your firefox wizard file into your /home/username folder ready to be imported.
    Start your firefox web browser. Click 'Bookmarks', then 'Manage Bookmarks', then on the 'File Menu' of the 'Bookmarks Manager' window, click 'import'. That will start the 'import wizard'. Click 'next;, and navigate to your '/home/username' folder. Find your bookmarks file to be imported and click 'Open'.
NOTE: For some reason I can't get tasks to restore by drag and drop in Ubuntu Jaunty Jackalope, I had to use the evolution import wizard for that.
TIP:
Simple Backup Config and Simple Restore are two excellent programs you can install in Ubuntu which can help you make your backups and restore work much easier.
Simple Backup Config and Simple Restore can be installed from 'Applictions'--'Add/Remove Programs' in Ubuntu, or sudo apt-get install

TIP:
The Ubuntu 'Desktop' CD's installer has the 'Migrate Documents and Settings' wizard, in Step 6 of 7 of the installation.
If you have room in your hard disk(s) to leave your old installation in place and install your new Ubuntu installation beside it or on another hard disk, you may be able to use the 'Migrate 
Documents and Settings' wizard at installation time to do a lot of the work for you.
It is still recommended to back up your files before any partitioning work on your hard disks.


Firefox Bookmarks (Firefox Method)
Sometimes we get too many bookmarks and we want to start again fresh and organize things a different way, but we don't want to lose some of or favorite bookmarks.

Export Bookmarks File
 Start your firefox web browser. Click 'Bookmarks', then 'Manage Bookmarks', then on the 'File Menu' of the 'Bookmarks Manager' window, click 'export'. That will start the 'export wizard'. Give your file a name that means something to you, or the day's date. Choose a folder to save it in such as /home/username/Backups, and click 'Save'.
Import Bookmarks File
Have the bookmarks file of your choice copied out of your backups folder or wherever you kept it and pasted out in the open in your /home/username folder ready to be imported.
Start your firefox web browser. Click 'Bookmarks', then 'Manage Bookmarks', then on the 'File Menu' of the 'Bookmarks Manager' window, click 'import'. That will start the 'import wizard'. Click 'next;, and navigate to your '/home/username/Backups' folder. Find your bookmarks file to be imported and click 'Open'.
 
I noticed that when I did this I ended up duplicating some of the bookmarks I already had rather than replacing them. That was annoying. Groups of sub folders can be deleted from the right-hand pane in 'manage bookmarks' by highlighting one and holding down the 'shift key' and clicking a lower one in a group. Then right-click on the red highlighted rectangle including all folders to be deleted and click 'delete'. You can empty your bookmarks right out completely this way if you want, ready to start a brand new collection , or import a different file..

    

Evolution
Restore(GUI navigation method)
Some people get too much mail, and it begins to take up a lot of room in their hard disk.

All you need to do is copy your .evolution addressbook, calendar, mail, memos, and tasks to your Backups directory for temporary storage. It's a good idea to put it in a folder with the date as part of the file name, such as ' 090626.evolution.bak' or something like that.
When you're ready, you can copy it from there to a more permanent backup, such as to another media like a USB external hard disk or a CD or DVD-ROM.

To restore, simply navigate to your .evolution directory again, copy and paste them in there, overwriting your new directories of the same name.
(Presuming of course, there's nothing in the ones you're about to overwrite that you'd like to save first).
It's best to make sure Evolution is not running while you restore it or it will probably crash, so just close evolution before you start restoring it. Usually, your e-mail will show up right away, when you go and start evolution up on your icon for it on your top panel. Your addresses, calendar appointments and tasks might not show up until after your re-start your computer.
    

File Compression

To compress a file in Ubuntu, you only need to right-click on it and click 'Create Archive', and then choose a type of file compression.
To extract files from an archive, we just right-click on it and click 'extract here'.

Compressed files take up less storage space and they are easier to transfer around. If you need to send them over a network they're more likely to arrive intact.
The only downside is, it takes time to compress and extract files, especially large files.
  • .zip files can be opened by Windows or Ubuntu
  • .tar files are a fast way to package a lot of files in one handy container without any file compression
  • .tar.gz files are fairly quick to compress or extract and have some file compression
  • .tar.bz2 files are slower to compress or extract and have maximum file compression

links: File Compression - Quick explanation, and File Compression Tools For Linux - Another explanation with just a few more details.
TIP: Use 'README' notes
It's often a good idea to make yourself some helpful notes to remind you about any extra information you might need to know someday about your backups.
You can always just leave them in the same folder as your backups.
'README' is a good name for such notes.

A plain text file is best, because those can be opened by almost any software, (even in a different operating system), and will probably stand up well to the test of time.

Maybe some day you'll be looking for some data that's included in a backup but you may not be able to remember which backup you left it in.
A 'README' note or maybe a 'MANIFEST' file you make today might save you a lot of time and stress some day in the future.

Sometimes you may use a special command or a certian program to create the backup.
You might want a copy of the restore command or a reminder of what the name of that program was so someday so you can restore your backup again.

With some kinds of backups you may need a reminder about how much disc space they'll use when they're decompressed.
In the case of a whole partition backup or a whole hard disk you may want to remember what partition number they belong to and how large a partition or hard disk you will need to restore the backup to.





Evolution Back-ups, Terminal commands method
These do the same job as the copying and pasting that is described above (email, addressbook, and tasks). It is faster and easier to use a script for this job. It's a good idea to get used to using terminal commands before you start learning how to make a script. (That's coming up next).
 
To make a new empty directory called 'Backups', (only if you don't already have one!)
mkdir Backups

I suggest making a new directory (folder) with the days date on it to store your new backup in,
mkdir Backups/090624.backup


To make copies of the stuff you want to back up,
code:
cp -r .evolution/addressbook Backups/090624.backup/
cp -r .evolution/calendar Backups/090624.backup/
cp -r .evolution/mail Backups/090624.backup/
cp -r .evolution/memos Backups/090624.backup/  
cp -r .evolution/tasks Backups/090624.backup/


Terminal commands for Restoring Evolution
code:
cp -r 090624.backup/addressbook .evolution/
cp -r 090624.backup/calendar .evolution/  
cp -r 090624.backup/mail .evolution/
cp -r 090624.backup/memos .evolution/   
cp -r 090624.backup/tasks .evolution/

NOTE: For some reason I can't get tasks to restore from the command line in Ubuntu Jaunty Jackalope, I had to use the import wizard for that.

When you get used to the commands, you can save yourself a lot of time compared with the time it takes to do some jobs by dragging and dropping or copying and pasting in 'GUI'.
Lots of things in Ubuntu will be explained in condensed form like this. It is a little difficult to get used to at first. When you realize it is really just the same things you are used to doing in 'GUI', you will come to understand the commands quite easily. It doesn't take very long before you'll learn to understand the commands as soon as you read them. Then you'll be able to make up your own. 

It is good practice to try using Linux commands because when you learn how to use the commands in terminal one at a time and become confident, you'll be able to progress to making up simple shell scripts.
Shell scripts are lists of commands that you can tell the computer to run. If you find a repetitve job that you want to make easier, you can make a shell script for it and run it like a program.

    
 

Make a backup script

Make your list of backup commands run automatically by making a backup script!
A script is a text file that has been given a name that ends with the extension .sh (short for 'shell', since they're really supposed to be called 'shell scripts', most most people just call them scripts.
A shell script contains a list of commands. They are the same as the commands you would type in a terminal normally, but this way you can run a whole list of commands in one hit.

If you type: introduction to shell scripting (or something like that) into google you will have pages and pages of helpful tutorials. My favorite one is from Rute User's Tutorial and Exposition, and the exact chapter is: 7. Shell Scripting If you want to really learn shell scripting, it would be best to refer to a proper tutorial like Rute's where everything is explained a lot better than in this page.

1. Make a directory in your /home/username folder and call it: Backups
you could also call it any other name you like.

One requirement for shell script is shell scripts need to have #!/bin/sh at the top.

Another requirement is it has to be given file permissions that mark it as being executable.

2. Create a new empty file in the Backups directory called: evo_bak.sh (or something similar).
gedit Backups/evo_bak.sh
3. Open the file called evo_bak.sh and type: #!/bin/sh (in the top right-hand corner).
4. type in the following commands:
for example,
#!/bin/sh

rm -rf Backups/new_evobkup

mkdir Backups/new_evobkup
cp -r .evolution/addressbook 
Backups/new_evobkup/
cp -r .evolution/calendar 
Backups/new_evobkup/
cp -r .evolution/mail 
Backups/new_evobkup/
cp -r .evolution/memos 
Backups/new_evobkup/
cp -r .evolution/tasks Backups/new_evobkup/

5. Take a look at the file permissions of the new evo_bak.sh file with: ls -l all_backups
herman@red:~$ ls -l Backups/
total 1
-rw- - - - - - - 1 herman herman    262 2007-04-15 09:40 evo_back.sh
-rw- - - - - - - 1 herman herman    262 2007-04-15 09:38 evo_back.sh~

Okay, as we can see there are no permissions allowed yet for this script to be executed by anyone.
For the script to work it must have permission to be executed.

We can fix that with a chmod command,
herman@red:~$ chmod 0755 Backups/evo_bak.sh

herman@red:~$ ls -l
-rwxr-xr-x 1 herman herman    262 2007-04-15 09:40 evo_back.sh
Good, now our script is ready to run.

We can test our script to make sure it works by typing the path and name of the script in out terminal, like this,
herman@red:~$ ./Backups/evo_bak.sh
We should see a new directory named: dailyevo_bkup appear inside our 'Backups' folder.
Inside that will be a backup of our evolution addressbook, calendar, mail and tasks folders.

If you want to keep (preserve) this particular backup, you must rename it. I suggest renaming it something like: 070414.evo.bak (or something like that), it's a good idea to include the date in it.
I'm just deleting mine for now, because in a few minutes I'll be making a new one to test the crontab command to make sure it works, so I'll be making another backup then too.
  
 

Use 'crontab'

Make your automatic backups happen automatically with crontab.

Program your computer to make regular backups at set times with crontab.
As soon as you learn how to use crontab, you'll be able to use crontab to make your computer do lots of other handy things for you as well.
The Official Ubuntu Wiki has a good page on cron, if you want to learn to use crontab you should read that as well, CronHowto.

The crontab command has three options, 
  • crontab-l
  • crontab-r
  • crontab-e
crontab -l causes the current crontab to be displayed in your terminal, (standard output), to list your current crontab.
To see if the cron daemon is already running, 
herman@testedgyeftbeta:~$ crontab -l
The display will feature a line like the following:
# m h  dom mon dow   command
 01 10 * * *   /usr/bin/playsound /home/herman/Examples/ubuntu\ Sax.ogg
That output tells me there is already one cron job running for my user account.


crontab -r
 - the -r option causes the current crontab to be removed!
This will remove (i.e. delete) your current crontab.
"Don't try this at home, folks", this is just a demonstration, you should be careful not to remove anything that might be important.
herman@testedgyeftbeta:~$ crontab -r
This will have removed my old crontab, to take a peek and make sure I'll do crontab -l again,
herman@testedgyeftbeta:~$ crontab -l
no crontab for herman
I used 'crontab -l' again to check, and sure enough, it's gone.


crontab -e 
The crontab -e command opens a file in /var/spool/cron/crontabs with the text editor Nano. Nano is the default command line text editor for Ubuntu.
See this website's Getting Started with GNU nano Text Editor.
The files in
/var/spool/cron/crontabs should only be edited via the crontab command.
When you exit the editor, the new crontab file will be installed automatically.
Code:
herman@testedgyeftbeta:~$ crontab -e

You will see a file open in your text editor, usually nano by default, (mine's nano anyway), and the empty file has a commented line like this (below).
 GNU nano 2.0.7                                        File: /tmp/crontab.BHz4Jj/crontab                    

# m h  dom mon dow   command









^G Get Help     ^O WriteOut         ^R Read File         ^Y Prev Page         ^K Cut Text        ^C Cur Pos
^X Exit         ^J Justify          ^W Where Is          ^V Next Page         ^U UnCut Text      ^T To Spell


You will want to type in a line of commands in the correct format in order to set up your cron job.

 'm'   column is for minutes, you can type any number here from 0 to 59, an * means every minute.
 'h'   column is for hours, you can type any number here from 0 to 23, or * for 'every'.
 'dom' column is for 'day of the month' from 1 to 31, or * for 'every'.
 'mon' column is for 'month of the year'use a number 1 to 12 or type 'march', or * for 'any'.
 'dow' column is for 'day of the week', mon=1, tues=2, wed=3, thu=4, fri=5, sat=6, sun=7
Note: with this method there is no column for 'user' because the file itself is already user-specific.

# m h  dom mon dow   command
15 3 * * *  /home/herman/Backups/evo_bak.sh
When done press ^o (ctrl+o) to save, then press 'enter', and ^x (ctrl+x) to close.

Use crontab -l to check and make sure the cron daemon really running, 
herman@testedgyeftbeta:~$ crontab -l
The display will feature a line like the following:
# m h  dom mon dow   command
15 3 * * *   /home/herman/Backups/evo.bak.sh

Now all you need to do is keep an eye out for your new daily evolution backup to appear in your /home/username/Backups directory.
 
It will be automatically updated every day at the same time as long as you leave the cronjob running.
Email can occupy large amounts of hard disk space.
Keeping a back up of all your email all the time like this doubles the amount of disk space used for your email. If you are short of disk space you may need to disable this cron job temporarily. # Placing a hash mark in front of the line in crontab will disable the operation if you want to stop it for a while.  

If you want to save a backup from any particular day, just rename the folder. You can name it anything you like, but I suggest making up a name that includes the date of the backup in it. For example: 070428evolution.bak

The main purpose of this is to make it quick and simple to copy these backups to a CD-ROM once in a while. You should copy them to a CD every once in a while. Then as soon as you are sure you have them safely copied to CD-ROM, delete them to recover your hard disk space.
 



Make a restore script
You can restore everything separately with a series of commands or you can make a matching restore script, let's call it: evo_rest.sh
#!/bin/sh

cp -r Backups/
new_evobkup/addressbook  .evolution/
cp -r 
Backups/new_evobkup/calendar .evolution/ 
cp -r 
Backups/new_evobkup/mail .evolution/
cp -r 
Backups/new_evobkup/memos .evolution/
cp -r Backups/new_evobkup/tasks .evolution/

Apply the chmod command again to enable the new shell script to be executed and check with ls -l that the file permissions are right.
herman@red:~$ chmod 0755 Backups/evo_rest.sh

herman@red:~$ ls -l
-rwxr-xr-x 1 herman herman    262 2007-04-15 09:40 evo_rest.sh
Now all you need to do to restore from Backups/daily_evobkup will be to open a terminal and  type:
herman@red:~$ ./Backups/evo_rest.sh
 
Or, try right-clicking on the script and click 'Open', then 'Run in Terminal'.

The script will instantly overwrite your evolution files with whatever is in the backup.

If you want to restore to an earlier date, copy your present daily_evobkup folder and rename it with today's date in the name to preserve your current files.
Then just find a folder with the date you need in your all_backups folder and rename that folder:
daily_evobkup   ...that will overwrite your current daily_evobkup folder and all its files. Then run the restore script. That will restore your evolution to an earlier time.





How to Back-up and Restore Added Software

Just go to /var/cache/apt/archives and copy all the packages you want before you delete your old operating system and record the packages to some media or another partition.
Then when you have a new operating system and you're ready to install your old software, just copy the packages into your /home folder and use the dpkg -i command.

To test this out with a simple example I copied the package for MacSlow's Cairo-Clock from one operating system's /var/cache/apt/archives to the /home/herman directory in a newer install,
    sudo dpkg -i cairo-clock_0.3.2-0ubuntu1_i386.deb
...and it worked fine!
This was just a simple program, I haven't gotten around to trying to see what is the most I can get away with yet. I imagine very often there will be programs with dependencies.

Another thing that might be interesting to try would be leaving a lot of packages on a CD-ROM and  seeing if Add/Remove programs will take it from the CD when deb cdrom is enabled in /etc/apt/sources.list. I know that APTonCD works something like that. I haven't tried that out yet either though.

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,
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.

sudo dpkg --list >> installedI.txt
You might run this command on a fresh installation and then keep a copy of the output file for the future.
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.

sudo dpkg --list >> installedII.txt
You might run this command on a mature installation.
This command will output another list of all installed packages to a text file and call it installedII.txt.

diff installedI.txt   installedII.txt >> addedsoftware.txt
Now you can run the diff command on the two files to get a list of all added software.

  1. Copy the 'addedsoftware.txt file into a new Ubuntu installation,
  2. Copy your backup of all the packages in your old /var/cache/apt/archives and paste it into your new /var/cache/apt/archives so you won't have to re-download the same packages again from the internet.
  3. run this command, (below),
sudo dpkg --set-selections < addedsoftware.txt

Then,
sudo apt-get dselect-upgrade
... and finally your newly re-installed operating system should have all the same software you had in your old installation.



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.    
 

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

Here is a link, Howto: Backup and restore your system! - Heliode - Ubuntu Web Forums.

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.

backup
sudo dd if=/dev/sda1 of=/media/OCZ_SAVER/ocz.image bs=4096 conv=notrunc,noerror

restore
sudo dd if=/media/OCZ_SAVER/ocz.image of=/dev/sda1  bs=4096 conv=notrunc,noerror
Where: You have two hard discs and the partition in the hard disc you want to copy the operating system to is equal size or larger than the partition you're copying from.
Where: 'OCZ_SAVER' is the name of the mount point for the file system you want to store your backup in.
Where: 'ocz.image' will be the file name for the backup image.

Note: It's wise to reduce the size of your partition using a partition editor like GParted before making your backup with the dd command. You may even wish to copy files out and store them elsewhere.
The reason this is a good idea is because the dd command copies everything exactly and perfectly the way it is, including empty space in your file system. It's not only a waste of disk space to be backing up empty space, but also we can run into problems restoring. We can use the dd command to copy to an equal or larger disk area but we can't copy a large partition to a smaller one. That means it's possible to get ourselves into a situation where we can't restore.

Notes:
  • You will need to restore GRUB if this is your main operating system, or run 'sudo grub-mkconfig -o /boot/grub/grub.cfg' in your main operating system after restoring.
  • You will probably want to resize the file system to fill the partition after using this command, see: What to do if your file system doesn't fit your partition - resize2fs
We can just as easily use the dd command to make a 'carbon copy' of our entire operating system into another partition, but now that file system UUID numbers are used for booting it can confuse GRUB so now it's best to make our backups to a file instead.

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,
dd if=/dev/sda of=/dev/sdb bs=4096 conv=notrunc,noerror
Where: 'sda' is the hard disk with the data in it and 'sdb' is an empty hard disk which is equal or larger in capacity than 'sda'.

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.


  backup security
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.

Maybe consider burying them in your back yard or something. (If the data isn't too hypersensitive). They'll be safe from fire and most natural disasters under some soil and you'll be able to dig them back up again some day.

Some people deliberately destroy old backups after a certain length of time too.

If you make encrypted backups, you will risk losing your data in the long run since the same software you used to encrypt the file may not still exist to decrypt the file again someday.
You will also still need to keep the keys or password somewhere safe. An encrypted backup is worse than useless if you lost the key or forgot the password.

Whatever you decide to do, just make sure you remember to think about security.

  
    







 

Back to Top