Backup Linux filesystem using Ruby Backup Gem
Read Time:2 Minute, 40 Second

Backup Linux filesystem using Ruby Backup Gem

0 0
0 0

Introduction

Ruby Backup Gem is a simple backup solution for Unix/Linux operating systems, It helps to back up the file system in the Ruby environment.

It can be used to back up the local filesystem in any virtual servers or physical servers, We have used this in our small production environment running on top of Ubuntu Linux Virtual Private servers.

To make sure to take the regular backup we have a scheduler in place. This helps to back up our critical production environment build with Ruby without having an additional backup solution totally free of cost.

Read more articles about Ruby

Starting Ruby Backup Gem installation

Install with Ruby and its dependencies to run below backup setup. We are not covering “how to install Ruby” in this guide. The Ruby backup gem we are about to install is on our existing development and production servers.

Let’s start to install the Backup gem.

$ sudo gem install backup

Prepare backup config file

Right after the installation, let’s start to generate the config.rb file for backup configuration.

$ backup generate:config

Right in the home directory, we could get a config file in the name config.rb.

/home/sysadmin/Backup/config/config.rb

Configuring Backup

Now let’s configure the backup, for instance, 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 the required changes.

To check for the config error, use the following command inside the config directory.

$ backup check

That’s all the required configuration.

Back up the file System.

To initiate a manual backup, run the below command with options and arguments.

$ backup perform -t production_database_name_here

This will confirm whether the config works.

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 the scheduler effective

every 1.day, :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"
end

Add the Scheduler 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 back up our Ruby development or production environment using Ruby backup gem.

Conclusion:

A simple backup solution for sites running on the ruby. No need to install with any additional packages except Ruby Backup gem. It takes lesser than 5 minutes to set up a file system backup using Backup gem. Hope this helps you to set up one, your feedbacks are welcome through below comment section.

Backup Linux filesystem using Ruby Backup Gem 1

About Post Author

Babin Lonston

Overall 14+ Years of experience in the IT field, currently working as a Senior Linux administration with Virtualization & Cloud. Being numismatist for a long time.
Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Leave a Reply

Your email address will not be published.

Previous post Allow nginx to upload more than 1 MB file
Install vsftpd with SSL/TLS in Ubuntu Server 4 Next post Install vsftpd with SSL/TLS in Ubuntu Server

Subscribe

Subscribe To Our Newsletter

Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

We promise not to spam you, and we don't usually send more than one email a week.

You have Successfully Subscribed!