I love Google. Google has so many wonderful products and services that really add value to my life, and business. One of these products, is Google Docs.
Google Docs is really neat, but anyone keeping all of their data in “the cloud” should be concerned. Anything could happen to the cloud… and with a little rain, all of our data could be washed away.
I’ve tried a few solutions to manually backup my Google documents. But remembering to backup your files regularly, is not an option.
So after some digging around, I found some tools that will allow you to setup regular Google Docs backups of your files.
What you’ll need:
- gdatacopier
- Google Data API
- Python version 2.2 or higher
Python is probably already installed on your Linux distribution. If not, you will need to install it. The Google Data API is available in several programming langauges. I chose Python for reasons unknown. The gdatacopier is a python script that talks to the Google Data API to talk to Google.
I decided that I would just install this for my user account on my server, and not for the whole server. We will first download the Google Data API and gdatacopier bundles from their respective websites, and extract them. I’ve not captured the output of the following commands. I encourage you to review the readmes with each package before starting.
Download two archives with wget:
$ wget http://gdatacopier.googlecode.com/files/gdatacopier-1.0.2.tar.gz
$ wget http://gdata-python-client.googlecode.com/files/gdata.py-1.2.4.tar.gz
Uncompress them:
$ gzip -d gdatacopier-1.0.2.tar.gz
$ gzip -d gdata.py-1.2.4.tar.gz
Un-tar them:
$ tar xf gdatacopier-1.0.2.tar
$ tar xf gdata.py-1.2.4.tar
Install the Google Data API:
$ cd gdata.py-1.2.4
$ python setup.py install –home=~
$ cd ..
Copy the gdatacopier library to $HOME/lib/python/ and create a symbolic link.
$ cp -r gdatacopier-1.0.2 ~/lib/python/
$ cd ~/lib/python
$ ln -s gdatacopier-1.0.2 gdatacopier
Next, you’ll want to add a line in your .profile or .bash_profile. You’ll want to edit an existing PYTHONPATH line, or create a new one:
PYTHONPATH=~/lib/python
export PYTHONPATH
Source in the profile by doing this:
$ . ./.profile
or
$ . ./.bash_profile
Finally, create a directory to store your Google Docs.
$ mkdir ~/GoogleDocsBackups
At this point, you should have the Google Data API and the gdatacopier library installed and ready to go. I created a simple script to actually do the backups. My script looks like this, and is located in a directory called “bin” created off of my home directory.
$ cat ~/bin/backup_googledocs
#!/bin/bash# Source in the profile for good # measure, since we'll be #running this from cron.. $HOME/.bash_profile
~/lib/python/gdatacopier/gdoc-cp.py \
–username ‘YourUserNameHere@gmail.com’ \
–password ‘YourPasswordHere’ \
–export default \
–google-id all \
–local ~/GoogleDocsBackups/
The script above basically exports ALL of your Google Docs Spreadsheets and Documents, and exports them as the default export format, which is Open Office format. You can read the documentation for the libraries on their websites and learn about other things they can do. The Google Data API, for example, lets you access all kinds of Google content.
Once you verify that your script works, and backs up your files successfully, you’ll want to schedule this in cron. Otherwise, we still have a manual process that we’ll probably forget to do.
$ crontab -e
This will open your crontab in your editor. You will want to add a line like the bottom line here:
SHELL=/bin/bash
# Backup my Google Docs each Day
10 6 * * * ~/bin/backup_googledocs
This will execute your script each day at 6:10am. I hope this provides some comfort for you. It does for me. I no longer have to worry about having a backup copy of my Google Docs.
![[del.icio.us]](http://www.theunixzone.com/wp-content/plugins/bookmarkify/delicious.png)
![[Digg]](http://www.theunixzone.com/wp-content/plugins/bookmarkify/digg.png)
![[Facebook]](http://www.theunixzone.com/wp-content/plugins/bookmarkify/facebook.png)
![[Twitter]](http://www.theunixzone.com/wp-content/plugins/bookmarkify/twitter.png)
One Comment
If you are receiving an error;
“Unknown error while attempting to login to Google servers”, the following fix might help as it did for me.
http://code.google.com/p/gdatacopier/issues/detail?id=18#c11
One Trackback
[...] http://www.theunixzone.com/2009/02/24/backing-up-your-google-docs/ [...]