A Quick and Easy Way to Back Up Posterous with Automator

June 29, 2009

One of the concerns I had with using Posterous for my blog was ensuring I had my own backup of my posts given the company is still in start-up mode and the content is hosted on their servers.  Luckily, they have an API, and if you are a Mac user it is very easy to use Automator to create a daily backup of your content.  You can set this up in about five to ten minutes and while it could be more sophisticated (see my comments at the end of this post), this probably works for a majority of the use cases.

Here’s how it works:

1) Get the content from Posterous
Posterous has a simple API for reading posts from their service.  The format of the request is http://posterous.com/api/readposts?hostname=foobar.  This request will return an XML document of your 10 most recent posts.  (Note: there is a parameter called num_posts that will let you specify up to the last 50 posts).  This is easy for Automator to grab.
First, you need to create a “Get Specified URLs” action with the URL of your site, and then save the results via a “Download URLs” action to a folder of your choice.  In my example below, I’ve created a folder called “Posterous Backups”:
Posterous Backup - part 1.png
2) Rename the file
If you stop here, Automator will save a file called readposts in your specified folder.  That’s fine, but if you run this on consecutive days, it will overwrite the file with the same name and you will have no historical record.  Here’s how you create a file that is named after the date it is saved.
Backup Posterous - part 2.png
The first “Rename Finder Actions” action renames readpost to file name of “YYYYMMDD-readposts”.  I’ve chosen this format as that is how I prefer to name files.  However this action is flexible and you can customize this to whatever is best for you.  The second “Rename Finder Actions” setting just adds .xml as a file suffix.  Therefore if we ran this today (June 29, 2009), the filename would be “20090629-readposts.xml”.
The last action is really for Growl users only.  It adds a Growl notification at the end so I know when the action has been completed.
That’s it.  You just backed up your Posterous blog.  You can run this manually, or I’d suggest you can save it as an Automator application and schedule the action to run daily using iCal.
What are the shortcomings of this solution?  A couple:
  • If you have more than 50 posts, it does not do a “full backup” of your posts each day.  Why does this matter?  If you have new comments or make any edits to posts that are greater than the last 50, you would potentially lose the comments and changes.  The good news however is the Posterous API supports pagination so you could probably design a smarter workflow to accommodate this.
  • This workflow doesn’t back up any media that is saved directly on Posterous servers.  I believe some media — pictures in particular — are hosted on Posterous depending on the method you use to post to the blog.
  • If you had to “restore” from this backup and you had more than 50 posts, you would have to chain multiple files together manually to restore all of the content.
With all of that said, this is a good way to get you started backing up Posterous quickly.  I am sure we can make this workflow even “smarter” and other folks will be will be coming up with more sophisticated backup solutions for Posterous soon enough, but it’s a good start.
  • Great info.. thanks! I was wondering how to do it.
    I do not have a Mac, but I am almost sure I will be able to do it with wget or curl from my Linux.
    you point me in the right direction.
  • Been a while since I toyed around on the command line, but it should be pretty simple -- conceptually you would use curl or lynx to pull the source of the page down and then redirect the output into a text file. Then set that up as a cron job say daily, and you have a regular backup.
  • yes, I did that way..
    Seems to be working, of course to put all that info into wordpress or Drupal is another story :)
blog comments powered by Disqus

Previous post:

Next post: