Running from cron

On my backup server I run from gdatacopier to backup my google docs. I had to fix two issues in order to get it to run from a bash script:

  • the PYTHONPATH had to be exported prior to running, or the script will fail because it requires gdata-python-client
  • the LANG envronment has to be set otherwise it will spill the following error in the log (if you bother to log the output from cron that is, otherwise it will just not work and you won’t know why, because the script works fine when ran manually)
Traceback (most recent call last):
File "/usr/local/bin/", line 541, in
File "/usr/local/bin/", line 537, in main
parse_user_input() # Check to see we have the right options or exit
File "/usr/local/bin/", line 519, in parse_user_input
export_documents(document_source, document_target, options)
File "/usr/local/bin/", line 222, in export_documents
export_filename = target_path + "/" + sanatize_filename(entry.title.text)
File "/usr/local/bin/", line 72, in sanatize_filename
filename = filename.decode(sys.getfilesystemencoding())
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc4 in position 3: ordinal not in range(128)

In order to fix it my backup script now looks like this:

echo "Syncing Google Docs"
export PYTHONPATH="/usr/lib64/python2.7/site-packages"
export LANG=en_US
/usr/local/bin/ -ou -p"xxxxxxxxx" /backups/google/docs