Install Rsync and Lsync on CentOS, Fedora or Red Hat

Have you ever needed to copy files from your local computer over to your web server? You may have previously used File Transfer Protocol (FTP) applications for this task, but FTP is prone to being insecure and can be challenging to work with over the command line. What if there was a better way? In this tutorial, we’ll be covering two popular utilities in the Linux world to securely assist in file transfers, rsync and lsyncd. We’ll show you how to install and use both in this article. Let’s dig in!

 

What is Rsync?

The first utility we’ll look at is called rsync, and this command is a real powerhouse! Most simply, it is used for copying files between folders, but it has some extra features that make it very useful. We’ll start with the most basic usage for rsync, and work into more complicated examples to show you how versatile it can be.

 

Install Rsync on CentOS, Fedora, or Red Hat

If you are using CentOS, Fedora, or Red Hat, you can use the yum package manager to install:

Note:
You’ll need to be the “root” user to install packages!

yum install rsync

 

Install Rsync on Ubuntu or Debian

If you are using Ubuntu or Debian, you can use the apt-get package manager to install:

Note:
You’ll need to be the “root” user to install packages!

apt-get install rsync

 

How to Use Rsync

The syntax for running rsync looks like this:

rsync -options <source> <destination>

You are not required to specify “options”, but you’ll always need to tell rsync a source and destination.  In this example, we’re using rsync to copy “file.txt” into the “/path/of/destination/” folder:

rsync /path/of/source/file.txt /path/of/destination/file.txt

Important
When you run rsync, remember always to put the “source” first, and “destination” second!

Now that you have the basics let’s try another common task. In this example, we’re going to use rsync to copy a directory from our local computer over to our web server “192.168.0.100”.

rsync -avHl /path/of/source/folder root@192.168.0.100:/path/to/destination/folder

Notice how just as before, we specified our source first, and destination second. One of the great things about rsync is that it performs remote transfers of data securely, through SSH. Using SSH is fantastic from a security point of view, and it allows you to use SSH keys to avoid typing passwords.

As one last example, let’s try copying something from your remote server “192.168.0.100” over to your local machine. Once again, rsync is the tool for the job!

rsync -avH  root@192.168.0.100:/path/of/remote/folder /path/of/destination/folder

We used some special options in that last example. Let’s break them down.

-a = archive mode (includes several commonly used options: -rlptgoD, check the rsync man page for detailed info.)

-v = print verbose messages to screen, (very helpful!)

-H = preserve hard links when copying

One of the great things about rsync is that it intelligently copies files. If only the last few bits of a file has changed, rsync solely copies the changes, rather than the whole file. Transferring only the changed parts of a file can be a huge time saver, but especially when copying files remotely like in that last example.

 

Introducing Lsyncd

Finally, we’ll talk about lsyncd. The utility lsyncd is somewhat similar to rsync in that it is used to synchronize two folders. Unlike rsync, which has to be run manually, lsyncd is a daemon. Sounds scary, but in computer terminology, daemons are merely applications that run as a background process. You usually don’t have to manually run daemons every time you want to use them, as they are typically configured to start automatically when your server boots. When you configure lsycnd correctly, it can automatically synchronize folders between two computers. Imagine if you didn’t have to manually create backups of your website on your web server every time you made a small change? That could be a real time saver! Let’s dig in.

 

Install Lsyncd on CentOS, Fedora, or Red Hat

If you are using CentOS, Fedora, or Red Hat, you can use the yum package manager to install:

Note
You’ll need to be the “root” user to install packages!

yum install lsyncd

 

Install Lsyncd on Ubuntu or Debian

If you are using Ubuntu or Debian, you can use the apt-get package manager to install:

Note
You’ll need to be the “root” user to install packages!

apt-get install lsyncd

 

How to Use Lsyncd

Unlike rsync, lsyncd runs as a daemon. You don’t run it directly. Instead, it starts automatically with your server at boot time, and runs silently in the background. It’s a great automated way to sync folders on your server! All we need to do is configure lsyncd, so it knows what folders to sync.

First, we’ll create some files and folders.

Create the configuration folder location
mkdir /etc/lsyncd

Create a folder to sync FROM, feel free to name it what you would like
mkdir /source_folder

Create the folder to sync TO
mkdir /destination_folder

Create the log folder location
mkdir /var/log/lsyncd

Make the log file
touch /var/log/lsyncd.log

Create the status file
touch /var/log/lsyncd.status

This is an example file for our sync tutorial
touch /source_folder/hello_world.txt

Next, we need to configure lsyncd to use our newly created files. Open a new file for editing using your favorite Linux text editor.

vi /etc/lsyncd/lsyncd.conf.lua

Paste in the following configuration, and save the file.

settings = {
logfile = "/var/log/lsyncd/lsyncd.log",
statusFile = "/var/log/lsyncd/lsyncd.status"
}
sync {
default.rsync,
source = "/source_folder",
target = "/destination_folder",
}

Now all that remains is to start the program! First, we’ll tell lsyncd to start automatically when your server boots:

systemctl enable lsyncd

Next, we’ll start lsyncd manually, (this only needs to be done once.)

systemctl start lsyncd

We’ve successfully installed lsyncd, but it is good practice to double check your work. We’ll check to see if it is running using this command:

systemctl status lsyncd

If you see a line that reads: active (running), it is running correctly!

Finally, we check the contents of /destination_folder to make sure that it contains our “hello_world.txt” file.

ls -l  /destination_folder
total 0
-rw-r--r-- 1 root root 0 Nov 17 07:15 hello_world.txt

 

You should see that “hello_world.txt” has been automatically synchronized over to “/destination_folder”. Everything is working! In practice, you can set “/source_folder” and “/destination_folder” to any folders you need synchronizing.

As you can see, these two utilities rsync and lsyncd are great tools for copying files and folders in Linux. Have questions about how to use these tools on your Liquid Web web server? Reach out to the Most Helpful Humans in Hosting. We’re here to help, 24×7!

 

How to Use IPMI

IPMI (Intelligent Platform Management Interface) is a great way to manage your server remotely. Having IPMI combined with a Liquid Web VPN is similar to having a remote Kernel-based Virtual Machine (KVM) attached to your server. You’ll be able to perform actions remotely which traditionally accomplished when physically present at the machine. This process includes viewing the startup process, changing BIOS settings, installing the OS, and even power cycling your server. This guide is intended to walk you through the IPMI web interface, and explain the various pages. If you need help accessing IPMI, try this Knowledge Base article instead!

Note:
Some functionality of the IPMI portal has been locked down by Liquid Web. As a customer, you have “Operator” level permissions. Only IPMI “Administrators” can perform specific actions in the web portal. This article covers what is primarily available to IPMI Operators!

This view is the first page displayed when you log into the IPMI web portal. There are a few important pieces of information on this page, including your IPMI IP address, the firmware revision of the IPMI BMC, and your system’s MAC addresses. The “Remote Console Preview” page gives you a small thumbnail display of what the video display would look like if directly connected to your server. Also note that you can perform some power cycling actions from this page, including “Power On,” “Power Down,” and “Reset.”

System Info within IPMI

 

While there is not much to look at on this page, it is one of the most important pages on the web portal! Clicking the “Launch Console” button will allow you to remotely connect to your server as if you had a KVM installed. When you click the button, your browser will prompt you to download a new file called “launch.jnlp.”

Note:
You will need Java installed to run this application.

Console Redirection page shows the "Launch Console" button

 

The “Event Log” page displays some fundamental logging information from the IPMI console. This page will keep a record of IPMI logins, and some other information on who accessed the system.

Note:
IPMI Operators will only be able to view these logs. Only IPMI Administrators maintain the ability to clear the logs.

Event Log shows who has accessed the server.

 

On this page, you can mount a CD-ROM ISO stored remotely on a Window share which can be useful if you would like to install a custom operating system remotely.

Note:
Installing a custom operating system may hamper Liquid Web’s ability to assist you! We have many officially supported operating systems available, ask your sales representative for more info.

IPMI gives you the ability to add your own OS.

 

The Virtual Media page allows you to upload a small binary image, (1.44MB max size,) directly to the IPMI controller in your server, allowing you to boot from legacy “floppy disk” images. While mostly un-necessary in today’s tech landscape, this option can still be helpful to some users.IPMI gives you the ability to add binary through floppy disk.

 

The Server Health page displays a small amount of information mostly permitting you to see some version information on the IPMI product.

Note:
Under normal circumstances, many of these fields will be blank, and there is limited information available on this page.

Check the version of your IPMI instance.

 

This page displays information gathered by sensors on the motherboard. You can see information on many physical aspects of your server here. For example, some data here includes fan speed, component temperatures, voltage readings on the CPU and RAM, and more.

Sensor Readings show fan speed, temps, CPU and RAM.

 

The “SOL” Console (Serial Over LAN Console) is a serial console connection to your server. With particular use cases, it is only useful for redirecting serial input/output over LAN.

The serial console connection, useful for redirecting serial input/output over LAN.

 

So covers the functionality available to IPMI Operators. When appropriately used, IPMI can be a valuable tool in maintaining your server. It provides similar level access as if you were physically present in front of your server. It used to be that this capability was only possible when purchasing additional expensive KVM hardware. Liquid Web Dedicated Servers have this functionality as a standard at no extra cost! Give us a call if you have any questions, or would like to discuss getting an IPMI capable server.