Mobaxterm Rsync practical examples using a bash terminal

MobaXterm is a beautiful tool for every DevOps engineer for having a local bash terminal, remote terminals, and RDP. Today, let us explore the rsync command with the mobaxterm bash terminal to copy or sync files. rsync is available by default in MobaXterm.

What is the Rsync command?

rsync in a nutshell is a utility for efficiently transferring and synchronizing files between a computer and a storage drive and across networked computers by comparing the modification times and sizes of files (reference: rsync Wikipedia)

Basic Syntax to copy files from one location to another using Rsync

The rsync command can be used in different situations and conditions, and the basic syntax is simple:

rsync <swithces> source-location destination-location

Switches are the command line parameters you can input to the rsync command, which control the behaviour of how rsync handles that invocation. Next, let’s go with an example of how to use the rsync command in MobaXterm.

How to use the rsync command in MobaXterm local bash terminal?

Let us have two directories, named source, and destination:

[admin@codetryout test]$ ls -l
total 0
drwxrwxr-x 2 admin admin   6 Nov  2 04:49 destination
drwxrwxr-x 2 admin admin 159 Oct 25 01:19 source

The source directory has a few files in it,

[admin@codetryout test]$ ls source/
file1.txt  file2.txt  file3.txt  file4.txt  file5.txt  file6.txt  file7.txt  file8.txt  file9.txt
Destination directory is empty.
[admin@codetryout test]$ ls destination/
[admin@codetryout test]$

Let us sync files from the source to the destination directory using rsync

[admin@codetryout test]$ rsync -av source/ destination/
sending incremental file list
./
file1.txt
file2.txt
file3.txt
file4.txt
file5.txt
file6.txt
file7.txt
file8.txt
file9.txt

sent 568 bytes  received 190 bytes  1,516.00 bytes/sec
total size is 0  speedup is 0.00
We used rsync with v, so it is showing verbose details.

Verifying the destination after rsync

[admin@codetryout test]$ ls destination/
file1.txt  file2.txt  file3.txt  file4.txt  file5.txt  file6.txt  file7.txt  file8.txt  file9.txt

This example illustrates how, locally, you can use the rsync command within the MobaXterm bash shell. Are you looking for more tips and tricks, configuration ideas, problems, and solutions with practical examples for MobaXterm? Please check our section: MobaXterm tips and tricks