– we create awesome web applications

New version - 0.3.1 - of astrails-safe released.

New stuff:

  • Internally switched from jeweler to bundler. Should not matter for users, but be sure to report any strange behaviour.
  • Plain FTP support, before that we only supported SFTP - contributed by seroy
  • mongodump support - contributed by Matt Berther

Thanks guys for your contributions.

We’re planning to spend some long overdue work on refactoring and adding new features. Just a couple of upcoming features:

  • Remote only S3 support. Back then when we added support for S3 it was not possible to upload straight to S3, so when you backup to S3 we store local file and then upload it. Amazon guys added this feature some time ago and we plan to support it.
  • Adding generic notifier support. We plan to start notifying by email and HipChat at the beginning, but adding new notification channels should be fairly easy.

The are multiple ways of configuring your Rails application for different environments (e.g. staging, production, etc). One of the popular ones is through environment variables. For example Heroku uses this type of configuration extensively.

We extracted a small gem that will allow you to manage it effectively.

The are multiple ways of configuring your Rails application for different environments (e.g. staging, production, etc). One of the popular ones is through environment variables. For example Heroku uses this type of configuration extensively.

One of the benefits of it is that configuration values are never stored in the source control system, which improves security (for sensitive configuration parameters) and also makes it easier to try different configuration setups w/o changing the sources or re-deploying the application.

On the other hand writing (ENV['PRIMARY_DOMAIN'] || "myapp.com") every time you need your domain string becomes cumbersome pretty fast, not to mention duplication and having the default repeated all over the place.

A competent programmer will of course only do this once, and re-use the value everywhere. Something like this:

PRIMARY_DOMAIN = ENV['PRIMARY_DOMAIN'].presence || 'myapp.com'
S3_BUCKET = ENV['S3_BUCKET'] || raise 'missing S3_BUCKET'

But it quickly becomes complicated, and again, quite a bit of similarly looking code that begs to be refactored out.

constfig is something I extracted from a couple of my latest projects. It allows you to do just that, have a configuration parameters stored in constants with values coming from environment variables and ability to provide defaults or have required parameters (i.e. fail if missing).

I just released version 0.0.1 of constfig to rubygems. Sources are of course on github.


Add this line to your application’s Gemfile:

gem 'constfig'

And then execute:

$ bundle

Or install it yourself as:

$ gem install constfig


There is only one function provided by the gem: define_config.

With a default (optional variable)

You can call it with a default, like this:

define_config :DEFAULT_DOMAIN, "astrails.com"

In which case it will first look if ENV['DEFAULT_DOMAIN'] is available, and if not will use the ‘astrails.com’. A constant DEFAULT_DOMAIN will be defined.

Without a default (required variable)

Or you can call it without the default:

define_config :DEFAULT_DOMAIN

In which case it will raise exception Constfig::Undefined if ENV['DEFAULT_DOMAIN'] is not available.

Variable type

One last thing. Non-string variables are supported. If you provide a non-string default (boolean, integer, float or symbol), the value that is coming from ENV will be converted to the same type (using to_i, to_f, and to_symbol). For the true/false types "true", "TRUE", and "1" will be treated as true, anything else will be treated as false.

In the case of required variables, you can supply a Class in place of the default, and it will be used for the type conversion. Like this:

define_config :EXPIRATION_DAYS, Fixnum

For boolean variables you can supply either TrueClass, or FalseClass.

Existing constants

This gem will not re-define existing constants, which can be used to define defaults for non-production environments.

Rails on Heroku

There is one caveat with Rails on Heroku. By default Heroku doesn’t provide environment variables to your application during the rake assets:precompile stage of slug compilation. If you don’t take care of it your application will fail to compile its assets and might fail to work in production. To take care of it you can either use Heroku Labs user-env-compile option, or (and this is what I’d recommend) you can use development defaults during assets:precompile.

For example in Rails you con do this:

if Rails.env.development? || Rails.env.test? || ARGV.join =~ /assets:precompile/
  DEFAULT_DOMAIN = 'myapp.dev'

define_config :DEFAULT_DOMAIN

In development and test environments it will use ‘myapp.dev’ ad PRIMARY_DOMAIN, but in production and staging environment it will fail unless PRIMARY_DOMAIN is provided by environment.

NOTE: make sure those configuration variables are not actually used for asset compilation. If they are, I’d go with user-env-compile.

Managing environment

You can use the dotenv gem to manage your ENV.

The OPEN 2010 conference was very well organized and had many interesting talks.

The side of low level, infrastructure things was presented by people from Red Hat, VMWare and IBM. The buzz words “SaaS”, “PaaS” and the likes were all over the place together with recent hot topic of virtualization.

On the application level there were interesting presentations about Django, PostgreSQL. And of course our own presentations on Ruby, Rails, NoSQL along with a longer, 2 hours “Introduction to Ruby” workshop.

The food was great too. That’s important ;).

We have 4 sessions there:

The Modern Approach

Using Cloud Computing, Web Wervices and Open-Source Tools to Build your Startup

The Modern Approach to Startups

Michael gave the keynote about the modern way to build startups:


when, why, and how


Vitaly gave a session about the NoSQL databases

Ruby on Rails

Web development that doesn’t hurt.

Ruby on Rails, Web Development that Doesn't Hurt

Boris gave a introduction session about Ruby on Rails


Ruby/Rails introduction

After the lunch we also hosted a longer (2 hours) ruby and rails workshop presented by Vitaly.

Note: this blog post was updated in 2012 with screenshots and direct links to slides

We are giving 4 out of 20 sessions at Open 2010, an Israeli open source conference.

Michael is giving the last keynote and me and Boris will be opening 2 of the 3 tracks: open startup and open enterprise.

I’m going to talk about “NoSQL, when, why, and how” and Boris is giving an introduction to Rails, web development that doesn’t hurt.

After the tracks we will also have a long 2 hour Ruby and Rails workshop.

See you there ;)

P.S. btw, Astrails is sponsoring this event together with a couple of smaller companies like IBM, Red Hat and VMWare :)

P.P.S. Big thanks goes to Raphael Fogel and People & Computers for organizing the whole thing.

There is a new (0.2.7) version of Astrails-Safe.

New features since 0.2.5:

  • default options for gpg now include --no-use-agent
  • support for command option for gpg
  • quote values in mysql password file
  • add lib to $:
  • [EXPERIMENTAL] Rackspace Cloud Files support

H. Wade Minter contributed support for Rackspace cloud files. I have no way of testing this, so please tell me if it works :)

To easy the development process, I added the ‘lib’ directory of the ‘currently running’ safe to the library load path”$:”. This enables to work on a new version of safe even though you have some version already installed. The files in ./lib will come first in the load path.


I just stumbled upon a problem with the gpg encryption on a freshly installed Ubuntu EC2 instance. The gpg was asking for a password on the console even though it was passed the --passphrase-file option with the file containing the password.

After some investigation I found out that gnupg’s default template configuration file now contains ‘use-agent’ options.

The result of it is that on the first invocation of astrails-safe it will work, but gpg will create a new ~/gnupg/gpg.conf file with ‘use-agent’ setting, so the next time you run astrails-safe it will fail and ask for the password on the console!

if you are running gpg 1.x series, just pass --no-use-agent to the “options” setting in the astrails-safe config in the ‘gpg’ section (since this 0.2.7 version this options is set in the default astrails-safe template config).

For gpg2 series, I suppose you’ll need to run the gpg-agent (actually I’m not sure, I didn’t research it too deeply, so I’ll be happy to get feedback on the issue)

I also added ‘command’ option support for gpg which allows to override the executable astrails-safe is using for the enctyption. For example you can have command "/usr/loca/bin/gpg" in the gpg section.

Just released a new 0.2.5 version of astrails-safe.

astrails-safe is our very simple to use backup script for mysql, postgres, filesystem, and subversion. It can store your backups locally, on Amazon s3 or on a remote SFTP server. Optional GnuPG enctyption completes the picture.


Since Github stopped to build gems we are moving to the gemcutter.


Damn, I just found this unpublished article in the blog admin…

How come it evaded my attention for 3 months??!!

Anyway, releasing it now thought this is all quite old news, going to announce 0.2.4 in a moment :)


I just pushed new version 0.1.9 of astrails-safe to github.

The main difference is a fix to an embarrassing bug in the S3 backup rotation code.

Thanks to Thuvarakan Tharmalingam for reporting.

Again, the reason it escaped was the fact that we don’t yet have full test coverage.

We are getting there though….


It looks like our astrails-safe gem is quite popular :). People started to contribute new features:


Everyone needs a backup, right? Unfortunately almost no one does though. Why?!

We needed something for ourselves and our customers. Something simple, free, configure-and-forget. Most of the time there is no need for something fancy, a simple tar + mysqldump can do the job for many small/medium sites.