Install Dumper Agent for Rails

Note for Heroku users

If you're using Heroku, go to the fetch setup section. Our fetch support works perfectly with Heroku Postgres or mLab.

Supported Stacks

Check if your Rails application stack is supported.

  • Ruby 1.9 or later
  • Rails 3.0 or later
  • MySQL
  • PostgreSQL
  • MongoDB (Mongoid)
  • Redis
  • Agent runs inside puma, thin, unicorn, passenger or resque (webrick and pow are also supported for testing)

agent

Installation

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

Add the following line to your Gemfile, and 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.

Go to the site and confirm that your app has been registered.

dashboard

If you see this, your server is ready for backup!

Troubleshooting

If your app won't show up on the page, the agent for Rails is not running. Visit our troubleshooting section to solve the problem.

Take the first backup

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

Click the green View Backups button, and you'll be navigated to the following page.

backupnow

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.

download

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 download button.

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

mysql -u root MY_DATABASE < MY_DUMP.sql

Activate automated daily backup

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

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

enable

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 checks the Dumper server 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 our Amazon S3 account, 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/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

We'll elaborate more on this topic soon.