/contrib/famzah

Enthusiasm never stops

Backup Google Sites automatically

4 Comments

I just found out how to make my Google Sites backup script almost non-interactive, so I decided to share. My usage pattern of this script is that I run it every month in the Linux console, and then the weekly backup of my hard disk takes care to additionally back up the information.

Why bother backing up Google Sites?
While Google are very reliable and probably they will never fail me here, I want to have an offline backup of my Google Sites pages in case someone steals my Google Account. So I back up. Online and offline, every week.

The backup script uses the wonderful free Java application “Google Sites Liberation“. My script is actually more like a sample Bash usage of this Java tool. You need to download the .jar file and store it in the same directory as the backup script. The source code follows:

#!/bin/bash
set -e
set -u
set -o pipefail

trap 'echo "ERROR: Abnormal exit." >&2' ERR

# config BEGIN

GUSER='username@gmail.com'
WIKI_LIST='wiki1 wiki2 wiki3'
JAR_BIN='google-sites-liberation-1.0.4.jar'
ROOT_BACKUP_DIR='./sites.google.com'

# config END

echo "We are using '$JAR_BIN'. Check for a newer version:"
echo '	http://code.google.com/p/google-sites-liberation/downloads/list'
read

echo "The directory '$ROOT_BACKUP_DIR' will be deleted!!!"
echo 'Press Enter to confirm.'
read

rm -rf "$ROOT_BACKUP_DIR"
mkdir "$ROOT_BACKUP_DIR"

echo -n "Enter the password for '$GUSER': "
read -s -r -e PASS
echo ; echo

for wiki in $WIKI_LIST ; do
	BACKUP_DIR="$ROOT_BACKUP_DIR/$wiki"
	echo "*** Exporting '$wiki' in '$BACKUP_DIR'..."
	echo "Press Enter to continue."
	read

	mkdir "$BACKUP_DIR"
	java -cp "$JAR_BIN" com.google.sites.liberation.export.Main \
		-w "$wiki" \
		-u "$GUSER" \
		-p "$PASS" \
		-f "$BACKUP_DIR"
	echo
done

References:

Advertisements

Author: Ivan Zahariev

An experienced Linux & IT enthusiast, Engineer by heart, Systems architect & developer.

4 thoughts on “Backup Google Sites automatically

  1. Hi, I am trying to backup my Google Sites where I am using Norwegian special language character set like “Æ” and “Ø”.

    This is my command from windoes:

    java -cp google-sites-liberation-1.0.4.jar com.google.sites.liberation.export.Main -h “sites.google.com” -w “mygooglesite” -u “myGoogleUsername” -p “mygmailpassword” -f “c:\backup\mygooglesite”

    But “Æ” and “Ø”(æ and ø) is not showing correctly after download.

    For instance the Norwegian word “Påvirker” shows like “pÃ¥virker” etc.

    Is there any way to fix and change this so that all characters are downloading correctly ?

    Thanks in advance

    • This seems like a known issue with “Google Sites Liberation” – reported issue 63. As comment #2 there states, the HTML pages are correctly saved in UTF-8, it’s just that the <meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ /> tag is missing. If you change the encoding in your browser to UTF-8 while viewing your page, you should be all set.

  2. I just did what you told me and it worked fine 🙂 Thanks.
    Is there a way to edit the google-sites-liberation-1.0.4.jar file and correct the tag myself? Thank you.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s