Transfer all of your posts from one Tumblr blog to another
I was prompted to create this utility when my wife wanted to move all of the blog posts from one of her Tumblr blogs to another. She could have manually reblogged each one individually and then deleted it on the source blog, but that would have taken forever (there were 1200+ posts to migrate!).
I thought, “Tumblr must have an API, and it probably supports automating this task.”. I did a quick read over of the API Docs and saw that it has everything I need. The only two hurdles I saw were using OAuth 1.0 and implementing all of the boilerplate HTTP to wrap the Tumblr API calls. Luckily, I found that the open source community had already handled this for me. I used the OAuth 1.0 library by mrjones and the gotumblr library by MariaTerzieva. With both of those pieces in place, it would be a simple task to plumb it all together and write the automation.
Getting the OAuth token was a bit interesting. Since this is a command line tool, there is no simple way for it to do the token granting process by serving a web page. Instead it outputs a URL for you to visit, which then, after granting access to act on your behalf, redirects you to the github repo, but with a special query parameter populated. You then take that value of that parameter and input it back into the application witch allows it to act on your behalf. It writes that token to a
.token file so that subsequent executions can re-use it.
After the token generation process, it is ready to start the migration. The utility accesses your Tumblr account to get a list of blogs that you own. From that list, it prompts you to select a “source” and “destination” blog. Meaning that it will reblog posts from “source” to “destination” and then delete the post from “source”. After some confirmation prompts, it will start the migration process. Due to limitations imposed by Tumblr, you are only allowed to post 250 times per day. So if you have more posts than that to migrate, you will have to run the utility again on the next day. It will simply pick back up where it last left off. Nifty, huh?
Because of the 250 post/day limitation, it took 6 days of running this utility once a day to get all of my wife’s posts migrated, but it still beats doing it all manually!
Seeing as how useful this utility was for her, I thought it would be good to open source in case anyone else needs to do the same. Hopefully Tumblr will eventually make this functionality a built in part of their UI, seeing as how it would certainly be much easier/efficient with direct access to the underlying datastore.