Filesystem backup using backup gem

Filesystem backup using backup gem Filesystem backup using backup gem

Introduction to Backup

Backup Gem is a simple backup solution for file-system backup in Ruby environment. This can be used under virtual machines are physical machines, We have used this in our small production environment running top of Ubuntu Linux servers. A regular scheduler in place to backup our critical production build with Ruby.

Read more articles about Ruby

Step 1 : Starting Backup Gem installation

Install with Ruby and its dependencies to run below backup setup.

Initially we need to install with backup gem.

$ sudo gem install backup

Then to Create the config.rb file for backup.

Step 2: Prepare backup config file

$ backup generate:config

Now in the home directory there will be a file created in the name config.rb.


Then if we need to take the backup for files, database, queue production db use the following command to create the model file.

$ backup generate:model --trigger production_database_name_here --databases="postgresql" --archives --compressor="gzip" --notifiers="mail"

Edit the files under Backup/config/ and make changes.

Check for the Configuration error using following commands while inside the config Directory

$ backup check

Step 3: Backup the file System.

To Manually take a backup

$ backup perform -t production_database_name_here

Step 4: Schedule for auto backup.

Now it’s time to automate the Backup using whenever gem

Install the Whenever Gem Using

$ sudo gem install whenever

Configure the whenever gem, first, we need to create a directory named Backup

$ mkdir config && cd ~/home/sysadmin/Backup/config

Then Run the command wheneverize to get create the schedule.rb file under /home/sysadmin/Backup/config

$ wheneverize

Add the content to get effect

every, :at => '3:00 am' do
command "/usr/local/bin/backup perform -t database --config-file /root/Backup/config.rb"
command "/usr/local/bin/backup perform -t file_backup --config-file /root/Backup/config.rb"

Add the Schedule to crontab using

$ whenever -w ~/Backup/config/schedule.rb

Then Update the Crontab using the following command,

$ whenever --update-crontab

That’s it we completed with setting up a simple backup solution to backup our Ruby environment.


A simple backup solution for sites running on ruby. No need to install with any additional packages except these gems. It takes lesser than 5 minutes to setup a file system backup using Backup gem. Hope this help you to setup one, comment below with your valuable feedback.