We are starting to use Google Docs quite a bit more at work and unsurprisingly the question of backup and offline availability comes into play. As part of the backup strategy we also wanted to capture incremental versions of the documents (on a daily basis) in the event we needed to go back to the prior versions.
To this affect I whipped up a small (120 lines) PHP script that will retrieve all your Google documents and save them to a local directory, in the event the document was created/updated in the last 24 hours, thus ensuring snapshot support. Each file name is prefixed with Ymd (Year,month,day) prefix to ensure name uniqueness and provides an easy way to spot similar files or files that were created/updated on the same day. The script has just two dependancies, cURL and Simplexml extensions, which most PHP 5.0+ installs should have.
I am publish the script for anyone with similar needs to use/improve under the BSD license...
I've made a few improvements to the script, some of which have been suggested by Philip (thanks), and since this looks to be an envolving project I've put it into GitHub.
1) Set time limit to -1 to allow successfully retrieve many files without hitting maximum execution limit.
2) Added extension to the saved files.
3) If ZIP extension is enabled, compress the files.
4) Store each day's backups in a separate directory.
5) Added "first run" detection, so that on the first run all files get backed up.
Nice useful script. And a couple of small changes that people might want to do:
A) set_time_limit(-1); on top
B) Add ".$format" as an extension to saved files
C) Ensure it works on initial runs and for new files (I commented out the continue; initially, but additional thought is required)