free hit counter GmailSync - Free automated backup solution using Gmail - Nauman Leghari's Blog
Monday, May 1, 2006 3:25 PM laghari78

GmailSync - Free automated backup solution using Gmail

Source Code for GmailSync is now available from CodePlex Gmailsync

Update ** Now with support for sub-directories and uploading files > 10 MB. See What's New.

What is GmailSync?
In short, GmailSync is "Blat" for "Gmail". Blat (http://www.blat.net/) is a win32 command line smtp client.
GmailSync is an automated backup tool to synchronize files on your computer to your gmail online storage. By using this, you can theoretically use almost unlimited amount of free space available on your gmail account.

Just imagine:
2.7 Gb * 99 (invites) = 267.3 Gb.

This tool is inspired by the article written on LifeHacker.
http://www.lifehacker.com/software/email/geek-to-live-automatically-email-yourself-file-backups-168156.php

How It Works?
GmailSync is little more than a simple email client. It uses another third party (free) program called Stunnel http://www.stunnel.org/ to wrap SMTP packets in SSL because Gmail SMTP server uses secure connections. For some reason, I am unable to get the EnableSSL property on SmtpClient to work. Stunnel is bundled with the download therefore you don't need to install or setup another other component before running GmailSync. GmailSync keeps track of the backed up files and only does differential backup the second time you run it.

Setting up GmailSync:
Setting up GmailSync is really really easy.

1) Download: Get GmailSync and extract it in any directory. This is developed with .NET Framework 2.0 therefore you may need to download the 2.0 runtime.
http://www.microsoft.com/downloads/details.aspx?FamilyID=0856eacb-4362-4b0d-8edd-aab15c5e04f5&displaylang=en

2) Installation: After extracting the contents from the zip file, just run the Install_Setup.bat file to register the stunnel service and start running it. It'll only take a second or two and then you'll see a little black computer in your taskbar tray.

3) Configure & Run: After installation, the only thing required is to configure the application. The common configuration parameters are source directory, Gmail username, Password.
The configuration settings are saved in the application configuration file, i.e. GSyncConsole.exe.config . Just open this file in notepad and there you can see all the configuration parameters and their default values.

-- Configuration File: GSyncConsole.exe.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <appSettings>
 <!-- The source directory for the backup -->
    <add key="SourceDirectory" value="C:\Data"/>
   
 <!-- Gmail dont' accept some extensions such as .exe or .chm. This parameter
  is used to identify such extensions and then use the ValidExtension property
  to rename the file before sending it to Gmail -->
 <add key="InvalidExtention" value=".exe|.chm"/>
   
 <!-- See the comments on InvalidExtension property -->
 <add key="ValidExtension" value=".pdf"/>
   
 <!-- GmailSync will automatically move the file to this directory after sending
  it to Gmail. If you don't specify this directory then the file remains in
  its original directory -->
 <add key="DestinationDirectory" value=""/>
   
 <!-- Used in the Subject of the email. It can be helpful in setting up a filter
  on Gmail -->
 <add key="EmailFilter" value="[backup]"/>
   
 <!-- The sender of the email message -->
 <add key="EmailFrom" value="yourgmailaddress@googlemail.com"/>
   
 <!-- The receiver of the email message -->
 <add key="EmailTo" value="yourgmailaddress@googlemail.com"/>
 
    <!-- Smtp Server: Leave it as it is as we are using Stunnel as the SMTP gateway -->
 <add key="SmtpServer" value="127.0.0.1"/>
   
 <!-- Smtp Port: Leave it as 465 -->
 <add key="SmtpPort" value="465"/>
   
 <!-- The username to authenticate with Gmail smtp server.
  For most cases, it is same as EmailFrom address -->
 <add key="SmtpUser" value="yourgmailaddress@googlemail.com"/>
   
 <!-- The password for the SmtpUser -->
 <add key="SmtpPass" value="yourgmailpassword"/>

 <!-- Ignore the following fields -->
 <add key="CheckAndRunStunnelOnStartUp" value="true"/>
  <add key="StunnelServiceName" value="stunnel"/>

<!-- Changes for Version 0.2 . If you are urgrading then only
 copy the following configuration settings to preserve your old
 settings -->
 
    <!-- Set this to true if you would like to include sub directories -->
 <add key="ScanSubDirectories" value="true"/>
 
 <!-- Splits the file into following size if greater than 10 MB -->
    <add key="SplitFileSize" value="5"/>  <!-- In MB -->
 
 <!-- Include the directory information into Email subject to distinguish between
 same name files in different directories -->
    <add key="FullDirectoryPathInSubject" value="true"/>
   
    <!-- Allows you to run multiple instances for different directories.
 If you set this, then you wont be able to preserve your
    settings if you move the directory. -->
    <add key="AllowMultipleInstances" value="true"/>
   
 <!-- End of Changes for Version 0.2 -->
 

  </appSettings>
 
</configuration>

Scheduling GmailSync for regular backups:
Currently there is no scheduling capability built into GmailSync therefore you may need to use Windows Task Scheduler to automate regular backups. The following script registers a task to run everyday at 1:00 am. You may want to change this file to run on any other time.

schtasks /create /tn "GmailSync" /tr "GSyncConsole.exe" /sc DAILY /st 01:00:00

More documentation on Scheduling tasks using Command line
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/schtasks.mspx?mfr=true

Download GmailSync (Latest Version)

Digg this

What's Next?
In the next release, I am planning to add few more features like,
- GUI instead of command line and configuration file.
- File filters
- Any other requested feature??

Old Versions:
Only download this if the newer version is not working for some reason and you have overwritten your copy of GmailSync.
Download GmailSync 0.2
Download GmailSync 0.1

Vista update for "GmailSync - Free automated backup solution using Gmail" by: marc1990

The problem with vista is that it has to install service as administrator. And by run the script as administrator: he wil start in a other dir(C:\windows\system32).
The solve is simple:
1. You wil need administrator permissen
2. Then you have to edit Install_Setup.bat.
cd stunnel -> cd C:\autobackup\stunnel
3. Run the script with administrator permission

Filed under:

Comments

# re: GmailSync - Free automated backup solution using Gmail

Monday, May 1, 2006 6:52 PM by Andy Brudtkuhl

Excellent app. I am currently wrapping it up in an interface that access the config file and launches the command line app.

Would you be interested in wrapping it in a web app?

# re: GmailSync - Free automated backup solution using Gmail

Tuesday, May 2, 2006 9:03 AM by pakspy

google is comming out with g-drive soon.... i dont see the point in killing your email account.

# re: GmailSync - Free automated backup solution using Gmail

Tuesday, May 2, 2006 12:55 PM by Adam

Hey Nauman, I tried this out on two different computers and it wouldn't work for me - somewhere along the line I'm getting an unhandled exception, and GsyncConsole has to close. Any ideas where I'm going wrong?

# re: GmailSync - Free automated backup solution using Gmail

Tuesday, May 2, 2006 3:53 PM by Nauman Leghari

Hi Adam,
Can you make sure that you are running .NET Framework 2.0?
If you are then can you try to run GmailSync from console to get the error.
Windows -> Run -> cmd , then run GmailSync.

-Nauman

# re: GmailSync - Free automated backup solution using Gmail

Tuesday, May 2, 2006 4:00 PM by Adam

Hey Nauman, I tried this out on two different computers and it wouldn't work for me - somewhere along the line I'm getting an unhandled exception, and GsyncConsole has to close. Any ideas where I'm going wrong?

# re: GmailSync - Free automated backup solution using Gmail

Tuesday, May 2, 2006 4:05 PM by Adam

I think I figured out the problem - I had an ampersand (&) in my Windows directory, which threw an error when parsing.

So I guess that's a bug to keep in mind - after a tried a different directory, it worked just fine.

# re: GmailSync - Free automated backup solution using Gmail

Wednesday, May 3, 2006 3:50 PM by Mark

How about support for multiple directories and subdirectories?

# re: GmailSync - Free automated backup solution using Gmail

Wednesday, May 3, 2006 6:28 PM by gw

Gmail is down now because of this!

# re: GmailSync - Free automated backup solution using Gmail

Wednesday, May 3, 2006 6:39 PM by Nauman Leghari

Mark,

Support for subdirectories is planned for next version. Along with File Split/Join ( for files > 10 MB). There will be a flag which you can use to run multiple instances of GmailSync, each for a unique directory.

Regards,
Nauman

# re: GmailSync - Free automated backup solution using Gmail

Wednesday, May 3, 2006 11:40 PM by MCM

Doesn't work on Windows x64:

Exception:System.Security.SecurityException: That assembly does not allow partia
lly trusted callers.
at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly a
sm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, Secur
ityAction action, Object demand, IPermission permThatFailed)
at GSyncConsole.Program.Setup()
at GSyncConsole.Program.Run()
at GSyncConsole.Program.Main(String[] args)
The action that failed was:
LinkDemand
The Zone of the assembly that failed was:
Internet

# re: GmailSync - Free automated backup solution using Gmail

Thursday, May 4, 2006 1:46 AM by Sudar

How about automatically changing the extensions of exe and chm files. May be you could change it to exe1 or chm1 or to a predefined format so that even those files could be backuped.

# re: GmailSync - Free automated backup solution using Gmail

Thursday, May 4, 2006 7:35 AM by Nauman Leghari

Sudar,

You can specify the ValidExtension in the configuration file. Currently, it changes .exe and .chm to .pdf (which gmail likes). It is configurable as I didn't know about all the extensions that gmail failed to receive and I dont want to hardcode anything in code.

MCM,
I didn't check it on x64. Are you running it as Administrator?

# re: GmailSync - Free automated backup solution using Gmail

Thursday, May 4, 2006 7:47 AM by Adrian

Is this a Windows-only app?

# re: GmailSync - Free automated backup solution using Gmail

Thursday, May 4, 2006 8:12 AM by Martin

This looks really good, thanks very much.

# re: GmailSync - Free automated backup solution using Gmail

Thursday, May 4, 2006 10:30 AM by Talbot

great program! Any clue how long it will be until the subdirectory functionality will be added? My heavily nested structure of folders makes implementing this kinda tough for now, but it may be the best backup option I have seen yet. Nice work!

# re: GmailSync - Free automated backup solution using Gmail

Thursday, May 4, 2006 7:23 PM by Nauman Leghari

Talbot,
I have just uploaded an updated version which will add files in subdirectories in the backup list.

Thanks for the comments.

# re: GmailSync - Free automated backup solution using Gmail

Friday, May 5, 2006 8:56 AM by Nader

Hi Nauman,

This soft is awesome ! Keep up the good work.

If it's possible could u add in the next release a feature that restore all the file on ur pc.

Thanks !

# re: GmailSync - Free automated backup solution using Gmail

Sunday, May 7, 2006 1:33 PM by Danish

there is exception when i try to run the GSyncConsole.exe

"The application failed to initialize properly...."

i already have the .Net 2 framework installed...

any ideas what is going on???

-danish

# re: GmailSync - Free automated backup solution using Gmail

Thursday, May 11, 2006 6:50 PM by kelle

i would like to backup just *one* file. (Is there an easier way to do this?) This probably falls in the "File Filters" category in your list of features for the next release, but I just wanted to let you know what would be ideal for me.

thanks for a great app!
-kelle

# re: GmailSync - Free automated backup solution using Gmail

Thursday, May 11, 2006 7:05 PM by kelle

two things:

- i set the scan sub directory value to false:
<add key="ScanSubDirectories" value="false"/> but it still transfers files in sub-directories!

- what program is used to split the files if they are larger than 10 MB? more to the point, how do i rejoin the split files?

thanks!
kelle

# re: GmailSync - Free automated backup solution using Gmail

Friday, May 26, 2006 1:27 PM by Sam

Fantastic program but I doesn't work on my computer though it's running on XP - have u any ideas what's the problem - can it be 'cos of my firewall or something else?

# re: GmailSync - Free automated backup solution using Gmail

Saturday, May 27, 2006 12:17 PM by matoos

Hey;
I dont know if this app does a win32 briefcase style sync or does it just sends files to gmail???