-
Products and Features
- How to Create and Manage VPC on CloudRaya
- Getting Started with CloudRaya Container Registry
- How to use Sudo on a CloudRaya Linux VM
- Keeping Your CloudRaya Linux VMs Up-to-Date
- Maximizing StorageRaya with Essential Practices
- Assign Multiple IP Addresses to Virtual Machine
- Generating a CloudRaya API key
- Simplify CloudRaya Management with API
- Deploying a Virtual Machine on CloudRaya
- Deploying a Kubernetes Cluster on KubeRaya
- Using StorageRaya – CloudRaya S3 Object Storage
- Opening Ping Access on Cloud Raya VM Public IP
- Maximize Your Storage Raya Access Speed with Content Delivery Network (CDN)
- How to Create Project Tag in Cloud Raya for More Organized VM Billing Report
- Exporting Cloud Raya VM to outer Cloud Raya's Infrastructure using Acronis Cyber Protect
- SSO Management on Cloud Raya
- Using the SSH key Feature in Cloud Raya Dashboard
- Cloud Raya Load Balancer, Solution to Distribute Load Equally
- Create your own VPN server with DNS-Level AdBlocker using PiVPN
- Fix Broken LetsEncrypt SSL Certificate due to Expired Root CA Certificate
- How to Make a Snapshot and Configure VM Backup in Cloud Raya
- How to Request Services or Licenses Products
- Adding, Attaching, and Resize Root Storage Disk in Cloud Raya VPS
- Managing your DNS Zone with DNS Bucket in Cloud Raya
- Create VM, Custom Package, Reinstall VM, and Adjusting Security Profile
- How to backup Linux VM via Acronis in Cloud Raya
- How to Backup Desktop Linux and Windows via Acronis in Cloud Raya
- Backing-Up Cloud Raya Windows VM Using Acronis Cyber Protect
- Load Balancing in Cloud Raya
- Establishing a VPN in Cloud Raya
- Generating an API Token
- Deploying a Virtual Machine in Cloud Raya
- Show Remaining Articles17 Collapse Articles
-
- How to backup Linux VM via Acronis in Cloud Raya
- How to Backup Desktop Linux and Windows via Acronis in Cloud Raya
-
- Maximizing StorageRaya with Essential Practices
- Using StorageRaya – CloudRaya S3 Object Storage
- Building a Static Website Using Storage Raya S3 Bucket
- Integrating S3 Storage Raya and Strapi for Asset Storage Optimization – Part 4
- Maximize Your Storage Raya Access Speed with Content Delivery Network (CDN)
- Managing Storage Raya from various tools and from various OS
- Binding NextCloud with CloudRaya S3 Object Storage as External Storage Mount
-
- How to use Sudo on a CloudRaya Linux VM
- Keeping Your CloudRaya Linux VMs Up-to-Date
- Implement Multi-Factor Authentication on CloudRaya Linux VM
- Assign Multiple IP Addresses to Virtual Machine
- Deploying a Virtual Machine on CloudRaya
- Configurating cPanel Using Ubuntu 20.04 on CloudRaya – Part 2
- Deploying cPanel Using Ubuntu 20.04 on CloudRaya - Part 1
- Exporting Cloud Raya VM to outer Cloud Raya's Infrastructure using Acronis Cyber Protect
- Using the SSH key Feature in Cloud Raya Dashboard
- Adding, Attaching, and Resize Root Storage Disk in Cloud Raya VPS
- Create VM, Custom Package, Reinstall VM, and Adjusting Security Profile
- How to backup Linux VM via Acronis in Cloud Raya
- Backing-Up Cloud Raya Windows VM Using Acronis Cyber Protect
- Deploying a Virtual Machine in Cloud Raya
-
Integration
- Implement Multi-Factor Authentication on CloudRaya Linux VM
- Accessing KubeRaya Cluster Using the Kubernetes Dashboard
- Building a Static Website Using Storage Raya S3 Bucket
- Integrating S3 Storage Raya and Strapi for Asset Storage Optimization – Part 4
- Integrating Strapi Content to Frontend React - Part 3
- Content Management with Strapi Headless CMS - Part 2
- Strapi Headless CMS Installation in CloudRaya - Part. 1
- Using SSH Key on CloudRaya VM with PuTTY
- Installing Multiple PHP Versions in One VM for More Flexible Web Development
- Replatforming Apps to K8s with RKE and GitLab CI
- OpenAI API Integration: Completions in PHP
- Building an Email Server on CloudRaya Using iRedMail
- Improving Email Delivery with Sendinblue SMTP Relay
- Building a Self Hosted Password Manager Using Passbolt
- How to Install Podman on Almalinux/Rocky Linux 9
- ElkarBackup: GUI Based backup Tools based on Rsync and Rsnapshot
- Improving Webserver Performance with SSL Termination on NGINX Load Balancer
- Using NGINX as an HTTP Load Balancer
- Automating Task with Cronjob
- Upgrade Zimbra and the OS Version
- Deploy Mailu on Rancher Kubernetes
- Export and Import Database in MySQL or MariaDB Using Mysqldump
- Backup & Sync Local and Remote Directories Using RSYNC
- Managing Storage Raya from various tools and from various OS
- Binding NextCloud with CloudRaya S3 Object Storage as External Storage Mount
- Simple monitoring and alerting with Monit on Ubuntu 22.04 LTS
- VS Code on your browser! How to install code-server on a VM
- Implementing Redis HA and Auto-Failover on Cloud Raya
- Using XFCE Desktop Environment on Cloud Raya VM
- Installing Python 3.7-3.9 on Ubuntu 22.04 Jammy LTS using PPA
- Implementing Continuous Integration with Gitlab CI and Continuous Delivery with Rancher Fleet
- Using Collabora Online on Cloud Raya NextCloud's VM
- Installing NextCloud in Cloud Raya- Detail Steps from the Beginning to the Very End
- Set Up High Availability PostgreSQL Cluster Using Patroni on Cloud Raya
- Set Up WAF KEMP in Cloud Raya Part 2
- Set Up WAF KEMP in Cloud Raya Part 1
- Using the SSH key Feature in Cloud Raya Dashboard
- Monitor Your Services Uptime Using Uptime Kuma
- Hosting Static Website with Hugo on Cloud Raya
- Kubernetes Ingress Controller using SSL in CloudRaya
- Reverse Proxy management using Nginx Proxy Manager
- Create your own VPN server with DNS-Level AdBlocker using PiVPN
- How to deploy Portainer on Linux to easily manage your docker containers
- High Availability Kubernetes Using RKE in Cloud Raya Part 3
- High Availability Kubernetes Using RKE in Cloud Raya Part 2
- High Availability Kubernetes Using RKE in Cloud Raya Part 1
- How to backup Linux VM via Acronis in Cloud Raya
- How to Backup Desktop Linux and Windows via Acronis in Cloud Raya
- Deploying Magento on Cloud Raya
- How to Install Nextcloud on Cloud Raya
- How to Install CWP in Cloud Raya
- How to Install Node.js and Launch Your First Node App
- How to install and secure MariaDB on Ubuntu 18.04 and 20.04 on Cloud Raya
- How to Install and Securing MongoDB on Ubuntu 18.04 and 20.04
- Classes: Post Installation on Ansible
- Classes: Install and Configure Ansible
- Classes: Introduction to Ansible for a robust Configuration Management
- How to Setup Active Directory Domain Service & DNS with Cloud Raya
- How to Host Your Own Docker Hub in Cloud Raya
- How to Setup Your Own Laravel with Nginx in Ubuntu 18.04
- How to Deploy Container in Cloud Raya using Docker
- Securing CentOS with iptables
- Install and Configure Squid Proxy in Ubuntu
- Installing Apache and Tomcat: A Quick Way
- Securing Ubuntu with UFW
- Install a Node.js and Launch a Node App on Ubuntu 18.04
- Installing LAMP in Ubuntu
- Installing LEMP Stack on Ubuntu 18.04
- Show Remaining Articles53 Collapse Articles
-
- Articles coming soon
-
- Implement Multi-Factor Authentication on CloudRaya Linux VM
- Configurating cPanel Using Ubuntu 20.04 on CloudRaya – Part 2
- Deploying cPanel Using Ubuntu 20.04 on CloudRaya - Part 1
- Integrating S3 Storage Raya and Strapi for Asset Storage Optimization – Part 4
- Integrating Strapi Content to Frontend React - Part 3
- Content Management with Strapi Headless CMS - Part 2
- Strapi Headless CMS Installation in CloudRaya - Part. 1
- Using SSH Key on CloudRaya VM with PuTTY
- Building an Email Server on CloudRaya Using iRedMail
- Improving Email Delivery with Sendinblue SMTP Relay
- Building a Self Hosted Password Manager Using Passbolt
- ElkarBackup: GUI Based backup Tools based on Rsync and Rsnapshot
- Improving Webserver Performance with SSL Termination on NGINX Load Balancer
- Using NGINX as an HTTP Load Balancer
- Upgrade Zimbra and the OS Version
- Deploy Mailu on Rancher Kubernetes
- Managing Storage Raya from various tools and from various OS
- Binding NextCloud with CloudRaya S3 Object Storage as External Storage Mount
- Simple monitoring and alerting with Monit on Ubuntu 22.04 LTS
- VS Code on your browser! How to install code-server on a VM
- Implementing Redis HA and Auto-Failover on Cloud Raya
- Using XFCE Desktop Environment on Cloud Raya VM
- Implementing Continuous Integration with Gitlab CI and Continuous Delivery with Rancher Fleet
- Using Collabora Online on Cloud Raya NextCloud's VM
- Installing NextCloud in Cloud Raya- Detail Steps from the Beginning to the Very End
- Set Up WAF KEMP in Cloud Raya Part 2
- Set Up WAF KEMP in Cloud Raya Part 1
- Monitor Your Services Uptime Using Uptime Kuma
- Create your own VPN server with DNS-Level AdBlocker using PiVPN
- How to deploy Portainer on Linux to easily manage your docker containers
- High Availability Kubernetes Using RKE in Cloud Raya Part 3
- High Availability Kubernetes Using RKE in Cloud Raya Part 2
- High Availability Kubernetes Using RKE in Cloud Raya Part 1
- How to Install Nextcloud on Cloud Raya
- Classes: Post Installation on Ansible
- Classes: Install and Configure Ansible
- Classes: Introduction to Ansible for a robust Configuration Management
- Connect Windows Active Directory on Cloud Raya with Azure AD
- How to Host Your Own Docker Hub in Cloud Raya
- How to Deploy Container in Cloud Raya using Docker
- Show Remaining Articles25 Collapse Articles
-
- Accessing KubeRaya Cluster Using the Kubernetes Dashboard
- Integrating S3 Storage Raya and Strapi for Asset Storage Optimization – Part 4
- Integrating Strapi Content to Frontend React - Part 3
- Content Management with Strapi Headless CMS - Part 2
- Strapi Headless CMS Installation in CloudRaya - Part. 1
- Creating Interactive Chatbot with OpenAI API in PHP
- Installing Multiple PHP Versions in One VM for More Flexible Web Development
- OpenAI API Integration: Completions in PHP
- Improving Webserver Performance with SSL Termination on NGINX Load Balancer
- Using NGINX as an HTTP Load Balancer
- Automating Task with Cronjob
- How to Deploy Django App on Cloud Raya VM Using Gunicorn, Supervisor, and Nginx
- How to Install Node.js and Launch Your First Node App
- How to Setup Your Own Laravel with Nginx in Ubuntu 18.04
- Install a Node.js and Launch a Node App on Ubuntu 18.04
-
- How to use Sudo on a CloudRaya Linux VM
- Keeping Your CloudRaya Linux VMs Up-to-Date
- Implement Multi-Factor Authentication on CloudRaya Linux VM
- Using SSH Key on CloudRaya VM with PuTTY
- Building a Self Hosted Password Manager Using Passbolt
- Improving Webserver Performance with SSL Termination on NGINX Load Balancer
- Export and Import Database in MySQL or MariaDB Using Mysqldump
- Backup & Sync Local and Remote Directories Using RSYNC
- How to Deploy Django App on Cloud Raya VM Using Gunicorn, Supervisor, and Nginx
- Set Up WAF KEMP in Cloud Raya Part 2
- Set Up WAF KEMP in Cloud Raya Part 1
- Using the SSH key Feature in Cloud Raya Dashboard
- How to backup Linux VM via Acronis in Cloud Raya
- How to Backup Desktop Linux and Windows via Acronis in Cloud Raya
- Securing CentOS with iptables
- Securing Ubuntu with UFW
- Show Remaining Articles1 Collapse Articles
-
- Configurating cPanel Using Ubuntu 20.04 on CloudRaya – Part 2
- Deploying cPanel Using Ubuntu 20.04 on CloudRaya - Part 1
- Integrating S3 Storage Raya and Strapi for Asset Storage Optimization – Part 4
- Integrating Strapi Content to Frontend React - Part 3
- Content Management with Strapi Headless CMS - Part 2
- Strapi Headless CMS Installation in CloudRaya - Part. 1
- Creating Interactive Chatbot with OpenAI API in PHP
- Installing Multiple PHP Versions in One VM for More Flexible Web Development
- Building an Email Server on CloudRaya Using iRedMail
- Building a Self Hosted Password Manager Using Passbolt
- Improving Webserver Performance with SSL Termination on NGINX Load Balancer
- Using NGINX as an HTTP Load Balancer
- Installing Python 3.7-3.9 on Ubuntu 22.04 Jammy LTS using PPA
- Reverse Proxy management using Nginx Proxy Manager
- Install and Configure Squid Proxy in Ubuntu
- Installing Apache and Tomcat: A Quick Way
- Installing LAMP in Ubuntu
- Installing LEMP Stack on Ubuntu 18.04
- Show Remaining Articles3 Collapse Articles
-
- Building a Static Website Using Storage Raya S3 Bucket
- Integrating S3 Storage Raya and Strapi for Asset Storage Optimization – Part 4
- Integrating Strapi Content to Frontend React - Part 3
- Content Management with Strapi Headless CMS - Part 2
- Strapi Headless CMS Installation in CloudRaya - Part. 1
- Creating Interactive Chatbot with OpenAI API in PHP
- Installing Multiple PHP Versions in One VM for More Flexible Web Development
- OpenAI API Integration: Completions in PHP
- Hosting Static Website with Hugo on Cloud Raya
- Deploying Magento on Cloud Raya
- How to Install CWP in Cloud Raya
- How to Setup Active Directory Domain Service & DNS with Cloud Raya
-
- Articles coming soon
Backup & Sync Local and Remote Directories Using RSYNC
There are many backup methods that had been brought on Cloud Raya’s Knowledge Base. In this tutorial, we will bring another backup & synchronization topic. Here, we will learn how to synchronize directories and certain files, from our main VM to another. So, it is similar to deploying DRC from our main VM.
The method we will bring in this tutorial is by using RSYNC. What is RSYNC, the command line, and the example of its application? Let’s find out.
What is RSYNC?
RSYNC is one of the powerful synchronization tools but quite easy to use. RSYNC runs on devices with Linux Based OS (Ubuntu, CentOS, Debian, etc.).
By using RSYNC, we can synchronize any file or folder from one device (source) to one or more other devices (destination).
The file transfer method on RSYNC can be through an SSH (secure shell) or RSH (remote shell) connection. Or even directly via the RSYNC daemon, so there will be an open RSYNC port on our device that will talk directly to an RSYNC client on another host.
However, in this tutorial, we will talk about how to use RSYNC from SSH connection, so that it will be more secure and most importantly, encrypted.
One of the capabilities of RSYNC is to synchronize which files differ between source and destination. (incremental backup). With this, we don’t need to always copy files in full in every synchronization process. This of course can save more bandwidth and your network, especially if you want to synchronize 1 device and another over the public network.
With RSYNC, we can also synchronize files and folders across OS, as long as they are still in one linux distribution.
RSYNC Command Format
Here is command structure on RSYNC usage:
rsync [optional modifiers] [source folder location] [destination folder location] |
There are optional modifiers that function to determine the action of our command. A group of main options from RSYNC includes:
▶️ -r
Recursive. Include directories and subdirectories as well as any files contained within the subdirectories.
▶️ -a
Archive. The complete version from –r, where –a is an alias from group of options: -rlptgoD
Include the recursion option, preserves authorizations, file modification date/time, and group as well as user ownership.
▶️ -v
Verbose. Displays a list of files that were copied during the sync process.
▶️ –delete
Delete, if the destination directory includes a folder or file which is missing from the source directory, delete it (can be done vice versa).
▶️ -z
Compress the files that we will synchronize so that the file size can be much smaller. RSYNC is smart enough to determine which file types need to be compressed or not
▶️ –exclude
Specify which file or folder patterns we want to exclude from the sync process.
▶️ –include
The opposite of the –exclude option, it defines a pattern of file or directory names to include in the sync process. Usually, users combine the “option include” with the “option exclude”.
▶️ –dry-run
Only shows what process your command will do without actually doing it.
▶️ –progress
It displays the Kb transferred, and the Kb/s transfer rate.
Those are some of the common RSYNC options that we can use. We can choose based on our needs and goals. But, in my personal opinion what essential to our need is -a -v and –progress, so that the files and folders that are synchronized are exactly the same as the source destination, we can check which files will be processed and also see the transfer rate.
Installing RSYNC
RSYNC is generally installed as a default feature on devices with Linux-based OS. However, it is possible that your device doesn’t have it yet.
If so, you can install RSYNC by running this command:
apt-get install rsync |
In this tutorial, we are going to use 2 VMs from Cloud Raya with Ubuntu as the OS. Don’t worry for you who use OS from other Linux distributions, the operational method will be similar. If there’s a minor difference, it would be just on the RSYNC installation process.
Both of the VMs will be in 2 different regions, Jakarta and Surabaya, to get better experience for the real DRC conditions.
Implementation
After we discover the command format and how to install RSYNC, let’s work try it and make a sample test.
▶️ Performing Local Backups
As the first test, let’s try to synchronize one directory with another, but still in the same VM.
Local Host – Source Dir ➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖ Files and folder list: RSYNC SYNTAX root@local-host:/usr/trial# rsync -avp source-dir / destination-dirsending incremental file list |
Local Host – Destination Dir ➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖ Files and folder list: |
↳ To synchronize all files and subfolders from the source destination, we can use the command above. In this tutorial, I will use additional options -v, -p to check what files will be synchronizedd, and how’s the progress going.
You may notice that there is a trailing slash (/) at the end of the first argument in the syntax, that this (/) specifies the contents of source dir.
Without the trailing slash, source dir, including the directory
, would be placed within the destination dir
. The outcome would create a hierarchy like the following:
Local Host – Destination Dir ➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖ Files and folder list: |
You can adjust it based on your project’s needs and goals.
▶️ Performing Backup to Remote System
Now we can jump to one of the main capabilities of RSYNC, which is doing a backup and synchronization within the local devices towards our other devices (remote system).
Local Host ➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖ Files and folder list: RSYNC SYNTAX root@local-host:/usr/trial# rsync -avp source-dir/ root@remote-host:/usr/trial/destination-dir sending incremental file list |
Remote Host ➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖ Files and folder list: |
↳ To sync with a remote system by using RSYNC, you just need SSH access configured between your local and remote machines, as well as RSYNC installed on both systems. After you have the SSH access verified between the two machines, you can sync the source-dir folder to a destination-dir folder that is on the remote machine.
To avoid entering passwords repeatedly while the SSH access between the local and remote is processing, you can configure the SSH key within the two devices.
For those of you who may not know how to connect 2 systems using the ssh key, we will talk about it in a different article.
Besides synchronizing the local device to the remote device, we can do the reverse activity as well by synchronizing the remote device with our local device. For the syntax, we can simply reverse it.
root@local-host:/usr/trial# rsync -avp root@remote-host:/usr/trial/source-dir/ destination-dir/ |
▶️ Using Exclude Options
RSYNC also has the ability to filter which files or folders we want to exclude in the synchronization process. Yes, we can use the –exclude option.
Local Host ➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖ Files and folder list: RSYNC SYNTAX root@local-host:/usr/trial# rsync -avp –exclude=*.txt source-dir/ root@remote-host:/usr/trial/destination-dir sending incremental file list |
Remote Host ➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖ Files and folder list: |
↳ So, in the sample, we will exclude the type file .txt from the synchronization process.
If you want to add another exclude condition, You can use the following array:
root@local-host:/usr/trial# rsync -avp –exclude={“*.txt“,”*.jpg”,”/presentation”,”/new/*”} source-dir/ root@remote-host:/usr/trial/destination-dir |
↳ So, in the above sample we will exclude the type file .txt, .jpg, folder presentation, and what’s inside the new folder from the synchronization process.
▶️ Using Exclude & Include Options
Besides exclude, we also able to filter with 2 direct conditions in the synchronization, include certain condition, and exclude other condition. And yes, we can combine argument –exclude and –include into 1 command.
Local Host ➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖ Files and folder list: RSYNC SYNTAX root@local-host:/usr/trial# rsync -avp –include=testing-file.txt –exclude={“*.txt“,”*.jpg”,”/presentation/“,”/new/*”} source-dir/ root@remote-host:/usr/trial/destination-dir sending incremental file list |
Remote Host ➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖ Files and folder list: |
If we see the output, the testing-file.txt is still synchronized even though they include in the condition of exclude *.txt dan /new/*. The subfolder is still synchronized even though what’s inside is not synchronized because it’s containing .txt file.
So, to use this option, make sure that you put the condition that you want to run first. Then, other conditions will be put behind it. (Include some, exclude the rest)
▶️ Multiple Destinations Synchronization
Because the natural method of RSYNC is to work on point-to-point synchronization, so there is no default command from RSYNC to conduct multiple destination synchronization.
However, we can do it with manual technique. One of the way to do it is by use the help from the command ‘for’ loop.
This is how to write Syntax Structure ‘for’ loop in providing RSYNC multiple destination:
$ for dst in [destination folder location 1] [destination folder location 2] [destination folder location ..] > do rsync [optional modifiers] [source folder location] $dst > done |
And for the sample implementation can be done as followed:
root@local-host:/usr/trial# for dst in root@remote-host-1:/usr/trial/destination-dir root@remote-host-2:/usr/trial/destination-dir do rsync -avp source-dir/ $dst done |
Common RSYNC Usage in Real Life Condition
The RSYNC usage in the real-life condition is unlimited, it includes these activities:
- Backup and DRC for the website/web application asset
- Backup to disk or usb stick
- Full server migration from 1 VM to another VM. Yes, it is a great potential from RSYNC that is very possible to implement. For those who need help with this migration level, our support team can help you from our Manage Service. Feel free to schedule consultation with us.
- And many others. You can determine the conditions yourself for activities related to synchronization and backup on Linux based OS.
Conclusion
Now we know how to backup and synchronize local & remote directories with RSYNC along with RSYNC’s benefits and usage. Hopefully, you find this article helpful.
On my next article, I will continue this series of article which is discussing about the other synchronization tutorial of 2 VMs. My tutorial final goal will be automatically synchronizing our main VM with our backup VM. Also, we will be discussing about dividing our 2 VMs load equally. So, if if any problem happen to one of our VM, the traffic will distributed automatically to our backup VM. With that, our application will be appeared to be always online seamlessly.
Visit our knowledge base page for more tutorial article. Or, if you don’t have Cloud Raya’s VM, You can join us by free register yourself here.