Tuesday, January 6, 2009

HOW TO: Use RSYNC for Backup

Problem:
You want to be able to backup your most important data but you are too lazy to copy and paste everything all the time.


Solution:
Use RSYNC!

This is a tool in the command line, but don't be scared off by that, it is very simple to use, and if you don't have the patience to fully learn it then read on and I'll show you a simple yet effective method of backing up your data.

Rsync is a useful command as it only backs up the files you have changed. So, the first time you run it it will backup everything you select, and in the future it will backup only those files that have changed from within the original selection.

For the purposes of this tutorial I assume the following:

1. User name: bob (so home folder is /home/bob/)

2. External hard drive is mounted at: /media/harddrive/


First of all its always a good idea to create a folder inside of your external hard drive before backing up:

Open a terminal and enter the following:

mkdir /media/harddrive/backup


Now we are going to be making the backup bash script. I prefer making a script as the command is quite long. First we need to make a folder to store the script in (so it is easier to access).

mkdir bash

Then we must create the bash script:


cd bash

gedit backup.sh


In this text file put the following in:


#!/bin/bash

sudo rsync -rltDvu --modify-window=1 --progress --delete --delete-excluded --exclude-from=/home/bob/Bash/BackupBigExclude.txt /home/bob/ /media/harddrive/backup


Explanation of commands:

rsync: this is the program used to sync the data. Rsync basically can check the destination data and see if any changes have been made in the source data so that ONLY the source data that has been changed is updated. VERY useful.


-r: copies directories recursively

-l: copies symlinks as symlinks

-t: preserves modification times

-D: preserves device and special files

-v: shows output (verbose)

-u: skips files that are newer at the destination


--modify-window=1: this is essential if you are backing up to a filesystem that is NOT ext3 or ext2, e.g. NTFS or FAT32. Basically in windows filesystem times are kept as even numbers. This command tells rsync to ignore file changes that are only 1 second in difference from the original. It is almost impossible that you will create a file, sync it, and in ONE second make a change and want to sync it again. So it is safe to use this option and it means that rsync will not back up everything every time simply because of a one second change.

--progress: simply shows the progress

--delete: this is important. Basically rsync syncs files that have been changed. But what if you delete a file from the source directory? This command deletes it from your backed up hard drive as well.


--delete-excluded: this deletes folder/files that you have specifically excluded.


--exclude-from=/home/bob/Bash/BackupExclude.txt: this is the other crucial command. This basically tells rsync to exclude the files/folders found in the list BackupExlude.txt. To create this list do the following:

gedit /home/bob/Bash/BackupExclude.txt

Now in the text editor it is entirely up to you what you want to exlcude.

This is my list:

MyDownloads

.VirtualBox

lost+found

I am not backing up my MyDownloads directory as I download a lot of files/data some of which I do not want to backup. and I am not backing up my .VirtualbBox directory as its a massive 2gb file that will update every time I log into VB, a waste of time/resources. Just list the files/folders here that are in your home directory that you do not want to backup


Here are some other hints/tips for the exclude command file:

1. To exclude hidden directories (all the directories that start with .) do: .*/

2. To exclude hidden files (all the files that start with .) do: .*


locations: the /home/bob and /media/harddrive/backup tells the script where to backup from and where to backup to.


There are numerous other settings/commands you can use, including compression, etc. My method is simply to have a place where I can access all my data with minimal hassle.


Suffice to say these commands are quite technical, but they all work for me.


Save the files.


Now open a terminal and type the following:


cd /home/bob/Bash

sh BackupBig.sh


This should run the backup, it may take a long time depending on how much data you have.


NB: Make sure you take care when changing any settings. If you are unsure please ask. In fact don't even change the location without first confirming.

For example, You want to backup /home/bob/ to backup /media/harddrive/ and you have lets say data x.txt, y.txt, z.txt on /media/harddrive/. If you do not create a separate folder all data on /media/harddrive will be erased. SO BE CAREFUL!


For more information on rsync commands see http://www.samba.org/ftp/rsync/rsync.html.

Saturday, January 3, 2009

HOW TO: Mount Ext3 Filesystem in Windows

Problem:
You have an external (or internal) hard drive that has been formatted using the "ext3" filesystem for Linux. Unfortunately, Windows cannot read ext3 natively.

Solution:
The program "Ext2 IFS" (despite its name) has the ability to display your ext3 formatted hard drive in Windows XP.

(on Windows)
1. Navigate to: http://www.fs-driver.org/

2. Download the executable file.

3. Connect your ext3 formatted hard drive

4. Install the Ext2 IFS executable.

5. Follow the prompts and you should be able to see your drive in the windows explorer.

Till now I have not had any problems with this and I have been able to use this tool for everything from copying files to watching movies.

Thursday, January 1, 2009

Happy New Year

To usher in the New Year, I have made a few changes to the look of this site, enjoy!