Backing up with S3

Last night, I threw together a little script for backing up content from my web server to Amazon S3. It’s not really feature complete, but it is good enough for what I need for now. It provides a very simple DSL for specifying what content should be backed up.

Download it here.

To specify content:

backup :foo do
  folder '/path/to/stuff'
  folders ['/path/to/things', '/path/to/blah']
  file '/path/to/allyourbase.rb'
end

Will produce this in S3:

-{date stamp}
  -foo
    -stuff
      -..content of stuff
    -things
      -..content of things
    -blah
      -..content of blah
    -allyourbase.rb

The idea is that you could have one backup block for each site (notice how the symbol passed to the block becomes the root folder). You could backup all the different parts of the application under one umbrella without having to worry about any collisions with other apps.

You’ll need the ‘aws-s3′ gem. To deploy this on your server, just put the files somewhere on your server, modify the configuration in the run_backup.rb script and point a cron task at it.

Now that they’re free

The LA Times website posted a clever short video poking fun at the new hands free cellphone law. In typical online video style, they provide an object/embed tag that you can use to stick this video on your own site. As seems typical of online versions of dead tree style publications, they just don’t get it. I first thought it was odd that their embed tag is about a kilobyte, and the UI for copying it makes it difficult to actually select the whole body, and they show an add before the video. What really gets me, though, is that the thing fucking auto starts. I had to move the think behind a link so you don’t see a fucking Lexus ad when you hit my homepage.

Video (and ad) after the jump:

Continue reading

Proper DSLs

Dave Thomas wrote a great article describing a troubling fad in Ruby development. Specifically, he addresses DSLs – Domain Specific Languages – that try too hard to look like English rather than trying to cleanly describe a problem domain. I’ve always had a distaste for things like RSpec and AppleScript, but had a hard time describing exactly why.

Ruby makes it easy to create a domain specific language and many of the existing ones make the language particularly compelling. Rails migrations are beautiful in their elegance and descriptiveness. Rake is a joy to use compared to most build systems. XMLBuilder is a very sexy way to build XML files. The things that I feel many new rubyists fail to grasp is that these DSLs are not trying to be English. They are trying to create a simple and clear way to solve a specific problem while adding as little unnecessary cruft as possible. Most importantly, they all remember the difference between code and human language. A good DSL is unapologetically code.