Install Dumper Agent for Rails

Requirements

  • Ruby 1.9 / Rails 3.0 or later
  • Agent runs as a thread inside puma, thin, unicorn, passenger or resque (webrick and pow are also supported for testing)

Installation

First, login to the Dumper site and create a new app_key from this page.

Add the following line to your Gemfile, then run bundle install:

gem 'dumper'

then create config/initializers/dumper.rb and add the following line:

Dumper::Agent.start(app_key: 'YOUR_APP_KEY')

Now, run rails server on your development machine as usual, and your app will be registered immediately.

Take the first backup

Now, the Dumper agent is live inside your application process. You'll be able to take a manual backup anytime you want. Let's try this now.

Click the DB, and you'll be navigated to the following page.

Press the Take a manual backup now button.

It will take 1 to 10 minutes for the agent to receive the scheduled job from Dumper. Wait for a while, and hit the reload button on the browser.

When you see this, your first backup is done and successfully uploaded to Amazon S3.

Good! Now let's try restoration - go ahead and press the Available link.

and click the Download button. Now you will get the .gz file.

Decompress the .gz file and run the following command on terminal.

# MySQL
mysql -u [user] [my_database] < xxxx.sql

# PostgreSQL
psql -U [user] -d [my_database] -f xxxx.sql

Activate on production

As the final step, activate the automatic backup for production.

It will just work on production in the same way as you deploy — check if your production servers are visible on this page.

Once activated, your server will start taking backups every day, starting tomorrow.

We recommend to keep your development environment disabled, as it might interfere with machines of your coworkers.

What’s happening on my server?

In the application server process, a new thread is created and periodically hits the Dumper API to see if a new backup job is scheduled. The agent is designed to be extremely efficient with memory, CPU, and bandwidth usage. You’ll probably never notice any difference with or without it.

When there's a pending job, the agent takes it and immediately spawns a child process to execute the long-running backup, upload the dump data to Amazon S3, and clean up everything that's temporarily created on your server.

If you want to conditionally start the agent, pass a block that evaluates to true or false to start_if method. That way, you can explicitly designate a specific server to take a backup, and dumper agent won't run in other processes.

Dumper::Agent.start_if(app_key: 'YOUR_APP_KEY') do
  Rails.env.production? && dumper_enabled_host?
end

Having trouble?

If you have a problem in any of these steps, shoot us an email at any time. We'll be happy to answer any questions!