The one problem with using Google Sites (as opposed to an old-school FTP site) is that there is no backup. While Google obviously has a good reputation, it still makes me a bit nervous to be without any kind of backup. I discovered the Google Sites Liberation tool, which allows you to export your sites. It is part of a larger effort by a team of Google engineers to make sure Google users have free access to their data.
Google Sites Liberation (GSL) is available as a Java JAR file download which you can run as a GUI application. However, I wanted to automate the backups, so I wrote a Groovy script to call GSL. Here is my very simple script, BackupGoogleSites.groovy:
import java.text.SimpleDateFormat
import com.google.sites.liberation.export.Main
/**
* Back up the various Google Sites for FEFC
* User: Jeff Olson (jeff@olsonzoo.com)
* Date: Dec 18, 2009
*/
def sites = [
'abf',
'community-outreach',
'creekside',
'small-groups',
'values',
'wiki',
'worship'
]
String backupDir = /C:\Backup\FFC Website Backup\Google Sites/
def username = 'your_username_here'
def password = 'your_password_here'
def host = 'sites.google.com'
def domain = 'firstfreechurch.org'
SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd")
def today = df.format(new Date())
sites.each { site ->
def location = "$backupDir/$today/$site" as String
println "\n\nBacking up $site for $today to $location\n"
def args = ['-h', host, '-d', domain, '-w', site, '-u', username, '-p', password, '-f', location]
// hack because ABF site fails when getting all revisions for some reason
if (site != 'abf') {
args << '-r'
}
Main.main(args as String[])
}To use this, just fill in your list of sites, the backup directory, username & password, host, and domain (if using Google Apps for your domain). The script will create a new subdirectory for each day and put each site into a subdirectory under that.
The "hack" for the 'abf' site is due to a so-far unexplained NullPointerException I get when trying to export all revisions that site, so I disabled the -r option for that one.
To run this Groovy script, I created a short batch file (yes, I'm running on Windows XP):
groovy -cp lib\google-sites-liberation-1.0.3.jar src\BackupGoogleSites.groovy
Oh, if you try this and your system complains it can't find 'groovy', you'll need to install the latest version of Groovy.