Gmail is, by its self, a great free email system but, with a bit of trouble, you can use it for purposes other than what it was originally designed for.
Although I have a Gmail mail account, I also use Gmail as a way of backing up my vital files. I do back up, on a daily basis, my entire /home/keckstein directory to an external hard drive but some of my files are so important to me that I can’t afford to lose them should I get visited by Billy The Burglar or, should the house burn down.
These are the files that I back up to a Gmail account and this is how I do it…..
I have explained (on my professional IT Site www.KeithEckstein.com), how I believe that we need to “Backup or Die” and here I shall show that it needn’t cost a penny as all the tools required are free.
Requirements
A Gmail Account
First things first, we’re not going to be able to back up to Gmail unless we have a Gmail account to back up to.
So, we need to head over to www.Gmail.com and sign up for a new account. If you already have a Gmail account and are signed into it, you’ll have to sign out so that you can create a new account.
I suggest that you name the account something like backup.mycomputername@gmail.com or mycomputername_backup@gmail.com – whatever makes sense to you and won’t ever get mistaken by you for a real email account.
Once your account is set up, you have a free offsite storage facility that can hold 7.5GB of data – the data can be transfered in chunks upto 25MB – all for free!
sendEmail
In order to get our backed upo data to our new Gmail account, we need a little bit of software called sendEmail.
This can be installed via Synaptic/Aptitude/apt-get for debain linux based operating systems. For RPMs and for Windows users, you should head to http://caspian.dotconf.net/menu/Software/SendEmail/ – download and install the version that is suitable for your system. The software works under : Linux, BSD, OS X, Windows 98, Windows NT, Windows 2000, and Windows XP. I’ve not tried it under Windows Vista/Windows 7 but should do so in the next few days. I’ll let you know if there are any problems.
There are loads of command line switches but don’t worry, I’ll explain the ones that we’re going to use.
chron/AT/Scheduling
Finally, you need to be able to create a scheduled task on your machine.
If you run Linux/BSD/OSX you will be able to use the cron command. 4 of my 5 machines run Linux so this is the way I go.
However, because I don’t see the need to wear a hair shirt if there’s a cashmere sweater available, I use GSchedule to manage my scheduled tasks. It works fine!
On a Microsoft Windows system, you can use the AT command or find your own scheduled task manager.
Identify your data , compress it and mail it out
To explain the process, I shall walk you through how I automatically backup one portion of my vital data by emailing it to a Gmail account.
My static financial data is held in a directory (or folder, if that means more to you), called /Financials – this lives in my home directory (for you Windows users, think of a folder that is stored in MyDocuments.)
I apologise to any Windows users that are expecting detailed instructions on how to do this on their platform. Too be honest, there is plenty of really good advice on Microsoft Technet and, if you get stuck, you could always pay me to come over and sort it out for you!
Seriously, I shall be writing some scripts for my Windows XP machine in the near future. When I have done so, I’ll post them here.
1). Remove last night’s backup
First I remove last nights backup… rm -rf /home/keckstein/Data/Backup/financials.tar
2). Tar my Financials directory
Then I tar my /financials directory. The command I use is… tar -cf /home/keckstein/Data/Backup/financials.tar /home/keckstein/Data/financials As you can see, I put the tarred file into a /Backup directory.
3). Compress my tarred file
Now I compress the tarred writing directory…. gzip /home/keckstein/Data/Backup/Writing.tar
I know that I could combine steps 2 and 3 – I prefer to keep them separate and simple – perhaps that’s wrong but, it works for me
4). sendEmail the file to Gmail
Finally, I use SendEmail to send the directory to a Gmail account…
sendEmail -f Mozart@localhost.com -u “financials” -m “financials” -a /home/keckstein/Data/Backup/financials.tar.gz -xu my_real_account_name@gmail.com -xp fake_password -t dummy_account_name@Gmail.com -s smtp.wanadoo.fr:587What does all that mean?
Well, the switches that I use are as follows….
-f ADDRESS from (sender) email address -u SUBJECT message subject
-m MESSAGE message body
-a FILE [FILE ...] file attachment(s)
-xu USERNAME username for SMTP authentication
-xp PASSWORD password for SMTP authentication
-t ADDRESS [ADDR ...] to email address(es)
-s SERVER[:PORT] smtp mail relay, default is localhost:25
Please note that I have changed my email details (username and password) for obvious reasons.
The End Result
Every morning, I notice that there is a new mail in my dummy_account_name@Gmail.com inbox with a Subject title of financials and a message body of financials.
This mail is from mozart@localhost.com – no one else knows about this mail account. Thus, any other mail that I receive on this account must be spam!
If I received other mail on this account, I would set up some sort of filter to mark as spam anything that didn’t come form mozart@localhost.com – at the moment, I don’t need to do that.
I never need to open the mail, or even look at my dummy_account_name@Gmail.com inbox – unless there is a problem.
Then, it gives me that nice warm feeling inside, knowing that I have got an earlier copy of a vital file.
If, for example, I have deleted or bolloxed-up (to use a technical term), one of my important financial spreadsheets (perhaps the billing spreadsheet?), then I can log on to the web interface for my dummy_account_name@Gmail.com mail account and retrieve an unbolloxed-up copy of that file.
As time goes by, I am accumulating a pile of backed versions of my vital files. When I start running out of space I shall delete some of the older ones to make space for the new. That, however, is going to be a long time away as my Gmail space is increasing faster than I can fill it!
In real terms, the scripts that I use send a whole bunch of files to this Gmail account every night. By keeping the files small and separate, I steer clear on the 25MB limit on Gmail transfers.
It also makes sense to send one file for financials, another for correspondence and yet another for planning etc.
This makes retrieving a file so much easier.
sendEmail Switches
The full range of switches for sendEmail is as follows……
sendEmail-1.55 by Brandon Zehm
Synopsis: sendEmail -f ADDRESS [options]
Required:
-f ADDRESS from (sender) email address
* At least one recipient required via -t, -cc, or -bcc
* Message body required via -m, STDIN, or -o message-file=FILE
Common:
-t ADDRESS [ADDR ...] to email address(es)
-u SUBJECT message subject
-m MESSAGE message body
-s SERVER[:PORT] smtp mail relay, default is localhost:25
Optional:
-a FILE [FILE ...] file attachment(s)
-cc ADDRESS [ADDR ...] cc email address(es)
-bcc ADDRESS [ADDR ...] bcc email address(es)
-xu USERNAME username for SMTP authentication
-xp PASSWORD password for SMTP authentication
Paranormal:
-b BINDADDR[:PORT] local host bind address
-l LOGFILE log to the specified file
-v verbosity, use multiple times for greater effect
-q be quiet (i.e. no STDOUT output)
-o NAME=VALUE advanced options, for details try: –help misc
-o message-file=FILE -o message-format=raw
-o message-header=HEADER -o message-charset=CHARSET
-o reply-to=ADDRESS -o timeout=SECONDS
-o username=USERNAME -o password=PASSWORD
-o tls= -o fqdn=FQDN
Help:
–help the helpful overview you’re reading now
–help addressing explain addressing and related options
–help message explain message body input and related options
–help networking explain -s, -b, etc
–help output explain logging and other output options
–help misc explain -o options, TLS, SMTP auth, and more
SendEmail can be found at http://www.caspian.dotconf.net/menu/Software/SendEmail
For Ubuntu/Debian users it is in the repository.
Conclusion
By sending a compressed copy of my vital data to a Gmail account, I can be sure that, should the worst happen, I can access my data from an internet cafe or from a friend’s PC.
By having daily copies of my vital data, saved offsite, I can manage pretty much every Disaster Recovery situation that I can think of.
All the best

[...] have written about this sort of backup script in far more detail in Backing up to Gmail on my IT blog at [...]