sbutler.com

Using Gmail for Backups

While writing a thesis it is obviously imperative to have foolproof backups in place. So why not backup to that free 2.7Gb Gmail account? Here’s what you have to do:

  1. Install “email” (Gentoo users: emerge net-mail/email)
  2. Edit /etc/email/email.conf (Gentoo users: as a minimum you must set REPLY_TO)
  3. Test the commands. They are:
    cd /path/to/your/thesis/
    tar -czf /tmp/thesis.tar.gz *.*
    email --blank-mail --smtp-server mail.yourserver.com –from-name “your name” –from-addr you@youremail.com –subject “Cron: Thesis Backup (`date`)” you@gmail.com –attach /tmp/thesis.tar.gz > /dev/null 2>&1
    rm -f /tmp/thesis.tar.gz
  4. Now add this as a /etc/crontab entry. This example sends the backup at 7am each day.
    0 7 * * * unixusername cd /path/to/your/thesis/; tar -czf /tmp/thesis.tar.gz *.*; email –blank-mail –smtp-server mail.yourserver.com –from-name “your name” –from-addr you@youremail.com –subject “Cron: Thesis Backup (`date`)” you@gmail.com –attach /tmp/thesis.tar.gz > /dev/null 2>&1; rm -f /tmp/thesis.tar.gz
  5. Final step is to create a Gmail filter! It would be nice if it was possible to stop the emails being downloaded via POP but I think this may require a filter that moves the incoming backup emails to Trash.

Obviously you don’t have to use this for backing up a thesis, it could easily be modified to backup whatever you want.
Note: I can’t see mention of TLS support in the client email, so that’s why I’ve suggested you use your own SMTP server rather than Google’s.

One Response to “Using Gmail for Backups”

  1. Haochi Says:

    I think you can only backup files that are less than 10MB.

Leave a Reply