Sunday, January 10, 2010

Automated Backup for Picasa Web Albums

This post describes a script for downloading all the photos in a Picasa Web account. My script is mainly intended for Linux users, because Windows and Mac users can use the Picasa desktop software to download Web albums easily.

The script is written in Ruby, and uses RubyGems. You will need to install the appropriate packages for your distribution. For example, in Debian and Ubuntu:
sudo apt-get install ruby rubygems libopenssl-ruby

The script uses Google's gdata RubyGem, so you need to install it:
sudo gem install gdata

Download and unpack the script from my GitHub gist. Create an account.yml file in the same folder, using the following template:
username: costan
password: "my secret password"

Run the script:
ruby picasa_downloader.rb

Find your photos, nicely grouped by album, in the picasa_username folder.

For Developers
I used Google's gdata RubyGem, and the Picasa Web Albums protocol guide and protocol reference.

The code is pretty straight-forward. There is one subtlety: for photos bigger than 1600x1200, the Web Albums API returns the URL for 1600x1200 thumbnails by default. To get the original uploaded file, I use the imgmax=d parameter in album feed URIs.

Motivation and Conclusion
I wrote this script because the Picasa desktop software does not seem to be able to download from Picasa Web Albums on Linux.

I hope you found my post useful. I welcome your comments, as well as your pull requests on GitHub.


  1. Hi, nice script but i am getting these errors (installed on ubuntu the way described)

    /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- net/https (LoadError)
    from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from /var/lib/gems/1.8/gems/gdata-1.1.1/lib/gdata/http/default_service.rb:16
    from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from /var/lib/gems/1.8/gems/gdata-1.1.1/lib/gdata/http.rb:15
    from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from /var/lib/gems/1.8/gems/gdata-1.1.1/lib/gdata.rb:17
    from /usr/lib/ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
    from /usr/lib/ruby/1.8/rubygems/custom_require.rb:36:in `require'
    from picasa_download.rb:14

    Any hints ?

  2. `gem_original_require': no such file to load -- net/https (LoadError)

    sudo apt-get install libopenssl-ruby

    worked and solved it... my bad!

    Nice work!!

  3. @Anonymous: I saw your comment on my way to work, and was just about to post the same workaround :)

    Thanks so much for noticing and bringing it up! I'm updating the blog post now.

  4. No worries! I wrote the comment before even googling the error.
    It is working great right now, thanks again for the script!

  5. hello. Thanks for your script. I have to report one problem:
    I have 2 albums with the same name ( I don't know, if it's normal/ possible, but it is :-)

    when script try download the second same name album, it crash with:
    picasa_download.rb:71:in `mkdir': File exists - charlie (Errno::EEXIST)
    from picasa_download.rb:71
    from picasa_download.rb:70:in `each'
    from picasa_download.rb:70

    I have to rename the album, but script may rename ( name(2) name(3) or something ) duplicated web album and continue his best work :-)



  6. Finally "Pay Dirt!"
    Thanks, this is exactly what I needed!

  7. Works fine, good work! I even managed to download albums belonging to other user by changing path in script.
    There's problem when album name contains chars which are not permitted in folder name (like "/"). Simple string replace solved my problem.

    1. hi tomaszf, that '/' is tripping me up too, any chance you could advise what i need to change in the script? don't know any ruby to implement the string replace...

  8. Hi,

    Under latest Fedora I'm getting the following error, any ideas?

    /usr/share/rubygems/rubygems/custom_require.rb:36:in `require': cannot load such file -- jcode (LoadError)
    from /usr/share/rubygems/rubygems/custom_require.rb:36:in `require'
    from /usr/local/share/gems/gems/gdata-1.1.2/lib/gdata.rb:21:in `'
    from /usr/share/rubygems/rubygems/custom_require.rb:60:in `require'
    from /usr/share/rubygems/rubygems/custom_require.rb:60:in `rescue in require'
    from /usr/share/rubygems/rubygems/custom_require.rb:35:in `require'
    from `'
    [stelios@stelios-pc sources]$ gem 'gdata', git: ''
    ERROR: While executing gem ... (RuntimeError)
    Unknown command gdata,

  9. @Stelios Your intuition was right, you should install the forked version of the gdata gem. It seems like Google's version does not work with Ruby 1.9. Here's how you can get the forked gem installed on your system.

    git clone git://
    cd gdata
    gem build gdata.gemspec
    gem install gdata-1.1.2.gem
    cd ..
    rm -rf gdata

  10. Cheers Victor, that worked perfect.
    One more question please. Is it possible to download only non existing folders or to select which folders to download?


  11. For big albums, resume / only download missing would be great.

  12. hallo,

    is there any way to have this script work on an incremental basis? i want to backup my instant upload folder in picasa every night, but i get the following error when trying to run the script for a 2nd time:

    backup.rb:68:in `mkdir': File exists - picasa_116447084024003061137 (Errno::EEXIST)
    from backup.rb:68

    i'm using a symbolic link to the original script, hence the different name