2006-11-02

Gmail as Backup System

I use the Ant Mail task to backup my system to Gmail. To get the 'mail' task to run, activation.jar and mail.jar will both need to be downloaded and placed in '${ANT_HOME}/lib'. I use '.bak' for the zip file extension, since Gmail will not permit zip attachments that have executables (i.e. '.bat' and '.exe' files). I created a filter in Gmail to archive these e-mails so they don't show up in my inbox. Note: Gmail caps e-mail attachments to 10MB. Here's the Ant 'build.xml' file:

<project>
  <property name="address" value="yourname@gmail.com"/>
  <property name="password" value="yourpassword"/>
  <tstamp/>
  <property name="save.file" location="./save-${DSTAMP}-${TSTAMP}.zip.bak" />
  <zip destfile="${save.file}">
    <fileset dir="/Users/home">
      <include name=".bash_profile"/>
      <include name="root/save/**"/>
      <include name="Library/Application Support/Firefox/Profiles/firefox/bookmarks.html"/>
      <include name="Library/Application Support/iTerm/Scripts/**"/>
      <include name="Library/Workflows/Applications/Finder/**"/>
    </fileset>
  </zip>
  <mail
    mailhost="smtp.gmail.com"
    mailport="465"
    from="${address}"
    tolist="${address}"
    user="${address}"
    password="${password}"
    ssl="on"
    encoding="mime"
    subject="Backup"
    message="Backup"
    files="${save.file}" />
  <delete file="${save.file}" />
</project>