Backing up your flickr account with Perl (not for the faint of heart)
[NOTE: see the first comment below, I added a script to get the auth_key for you.]
Today I decided that I would like to backup my flickr account to my Mac. After a few attempts at using a Java based UI tool "FlickrBackup", which had terrible network performance for some reason, I fell back to my trusty old Perl skills.
Here is what I did:
1. Install Net::Flickr::Backup
To install this module, open up a terminal and type:
cpan
When CPAN loads up, type:
install Net::Flickr::Backup
Its pretty much that easy.
2. Go to Flickr.com and create an API key. Create one for a web application, and enter pretty much any valid url as your callback. I know, its not a web application...just do it, k?
3. Get an auth_token. This is harder than it needs to be, but here is how I got it done:
- First get a frob. This page shows you how to do it manually. Mac OS X has a terminal command, "md5" that you can run to make your api_sig value. for example:
md5 -s 000005fab4534d05api_key9a0554259914a86fb9e7eb014e4e5d52permsread
Which would yield a MD5 hash of: f2c52fb8fd3124314227bbc0f48003d3
Which it turn would mean the auth url needs to be like:
http://www.flickr.com/services/auth/?api_key=9a0554259914a86fb9e7eb014e4...
Once the URL is constructed, paste it into a browser, and approve access to your account. Once you approve, flickr calls your callback url. I just made my callback a bogus url like http://mattmackenzie.com/authdummy/
The frob will be in the URL that flickr redirects to. Copy it from your address bar, and vist this page. Paste the frob into the input value box, make sure "sign url with
Next, create a file called flickr_backup.cfg, and type the following into it:
[flickr] api_key=API KEY api_secret=SECRET auth_token=AUTH TOKEN api_handler=LibXML [backup] photos_root=/Path/Where/You/Want/Photos/BackedUp [rdf] do_dump=true rdfdump_root=/Path/Where/You/Want/Photos/rdf
and another file named flickr_backup.pl that is like this:
#!/usr/bin/perl
use Net::Flickr::Backup;
use Log::Dispatch::Screen;
my $flickr = Net::Flickr::Backup->new("/path/to/flickr_backup.cfg");
my $feedback = Log::Dispatch::Screen->new('name' => 'info',
'min_level' => 'info');
$flickr->log()->add($feedback);
$flickr->backup();
Now, just run it: perl flickr_backup.pl
I'll clean this up some time when I get some spare cycles, so sorry about the bad formatting and sketchy instructions.




