Logo
  • Ubuntu
  • CentOS
  • Debian
  • Fedora
  • RedHat

Zaloha.sh – A Simple Local Directory Synchronizer Script for Linux - DesignLinux

May 29 2020
designlinux 0 Comments

Zaloha.sh is a tiny and simple shell script used to synchronize two local directories: a source directory and a backup directory. It employs standard Linux/Unix tools such as find, sort, awk, mkdir, rmdir, cp and rm to support its underlying functionality.

Zaloha obtains information about the directories and files via the find command. Both directories must be available locally i.e mounted to the local file system. It also features reverse-synchronization, and can optionally compare files byte by byte. Besides, it asks users to confirm actions before they are executed.

In this article, you will learn how to install and use zaloha.sh to synchronize two local directories in Linux.

Installing Zaloha.sh in Linux

To install Zaloha.sh, you need to clone its Github repository using the git command-line tool, but before that, you need to install git as shown.

# dnf  install git		# CentOS/RHEL 8/Fedora 22+
# yum install git		# CentOS/RHEL 7/Fedora
$ sudo apt install git		# Ubuntu/Debian

Once git is installed, run the following command to clone the remote repository to your system, move into the local repository, then install the zaloha.sh script in a location in your PATH e.g /usr/bin and make it executable as shown.

$ git clone https://github.com/Fitus/Zaloha.sh.git
$ cd Zaloha.sh/
$ echo $PATH
$ sudo cp Zaloha.sh /usr/bin/zaloha.sh
$ sudo chmod +x /usr/bin/zaloha.sh
Install Zaloha.sh in Linux

Install Zaloha.sh in Linux

Synchronize Two Local Directories in Linux Using Zaloha.sh

Now that zaloha.sh is installed in your PATH, you can run it normally like any other command. You can synchronize two local directories as shown.

$ sudo zaloha.sh --sourceDir="./admin_portal/" --backupDir="/var/www/html/admin_portal/"

After running it, zaloha will analyze the two directories and prepares the commands necessary to synchronize the two directories.

Sync Two Local Directories in Linux

Sync Two Local Directories in Linux

You will be prompted to confirm the actions to be executed: “Execute above-listed copies to /var/www/html/admin_portal/? [Y/y=Yes, other=do nothing, and abort]:”. Answer yes to proceed.

File Synchronize Confirmation

File Synchronize Confirmation

Backup to External/Removable USB Media

You can also backup to a removable media (e.g /media/aaronk/EXT) mounted to the local file system. The destination directory must exist for the command to work, otherwise you will get the error message “Zaloha.sh: <backupDir> is not a directory”.

$ sudo mkdir /media/aaronk/EXT/admin_portal
$ sudo zaloha.sh --sourceDir="./admin_portal/" --backupDir="/media/aaronk/EXT/admin_portal"
Backup Files to USB Device

Backup Files to USB Device

Backup Changes from Source to Backup Directory

Now make more changes in the source directory, then run zaloha.sh once more to back up the changes in the external disk as shown.

$ mkdir /home/aaronk/admin_portal/plugins
$ mkdir /home/aaronk/admin_portal/images
$ sudo zaloha.sh --sourceDir="/home/aaronk/admin_portal/" --backupDir="/media/aaronk/EXT/admin_portal"

Zaloha.sh will create the new directories in the backup directory and copy any new files from the source as well as highlighted in the following screenshot.

Sync New Changes in Linux

Sync New Changes in Linux

Reverse Synchronize Changes from Backup to Source Directory

Assuming you have made changes in the backup directory to files that already exist in the source directory, you can make the changes reflect in the source directory using the reverse sync feature, enabled using the --renUp option.

$ zaloha.sh --revUp --sourceDir="/home/aaronk/admin_portal/" --backupDir="/media/aaronk/EXT/admin_portal"
Reverse Sync from Backup to Source

Reverse Sync from Backup to Source

Note that any new files or directories created in the backup directory that doesn’t exist in the source directory will also be deleted as indicated in the following screenshot.

Reverse Synchronize Files

Reverse Synchronize Files

You can tell zaloha to follow symbolic links on the source directory using the --followSLinksS option and on the backup directory using the --followSLinksB option.

$ sudo zaloha.sh --followSLinksS  --followSLinksB --sourceDir="./admin_portal/" --backupDir="/var/www/html/admin_portal/"

To view the Zaloha documentation, run the following command.

$ zaloha.sh --help

That’s all for now! Zalohah.sh is a small and simple Bash-based backup script to synchronize two local directories in Linux. Give it a try and share your thoughts with us via the feedback form below.

Sharing is Caring…
Share on FacebookShare on TwitterShare on LinkedinShare on Reddit

Related

Tags: commandline tools

How to Fix “Failed to set locale, defaulting to C.UTF-8” in CentOS 8

Prev Post

How to Install OwnCloud in Debian 10

Next Post
Archives
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • July 2022
  • June 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
Categories
  • AlmaLinux
  • Android
  • Ansible
  • Apache
  • Arch Linux
  • AWS
  • Backups
  • Bash Shell
  • Bodhi Linux
  • CentOS
  • CentOS Stream
  • Chef
  • Cloud Software
  • CMS
  • Commandline Tools
  • Control Panels
  • CouchDB
  • Data Recovery Tools
  • Databases
  • Debian
  • Deepin Linux
  • Desktops
  • Development Tools
  • Docker
  • Download Managers
  • Drupal
  • Editors
  • Elementary OS
  • Encryption Tools
  • Fedora
  • Firewalls
  • FreeBSD
  • FTP
  • GIMP
  • Git
  • Hadoop
  • HAProxy
  • Java
  • Jenkins
  • Joomla
  • Kali Linux
  • KDE
  • Kubernetes
  • KVM
  • Laravel
  • Let's Encrypt
  • LFCA
  • Linux Certifications
  • Linux Commands
  • Linux Desktop
  • Linux Distros
  • Linux IDE
  • Linux Mint
  • Linux Talks
  • Lubuntu
  • LXC
  • Mail Server
  • Manjaro
  • MariaDB
  • MongoDB
  • Monitoring Tools
  • MySQL
  • Network
  • Networking Commands
  • NFS
  • Nginx
  • Nodejs
  • NTP
  • Open Source
  • OpenSUSE
  • Oracle Linux
  • Package Managers
  • Pentoo
  • PHP
  • Podman
  • Postfix Mail Server
  • PostgreSQL
  • Python
  • Questions
  • RedHat
  • Redis Server
  • Rocky Linux
  • Security
  • Shell Scripting
  • SQLite
  • SSH
  • Storage
  • Suse
  • Terminals
  • Text Editors
  • Top Tools
  • Torrent Clients
  • Tutorial
  • Ubuntu
  • Udemy Courses
  • Uncategorized
  • VirtualBox
  • Virtualization
  • VMware
  • VPN
  • VSCode Editor
  • Web Browsers
  • Web Design
  • Web Hosting
  • Web Servers
  • Webmin
  • Windows
  • Windows Subsystem
  • WordPress
  • Zabbix
  • Zentyal
  • Zorin OS
Visits
  • 1
  • 358
  • 614,730

DesignLinux.com © All rights reserved

Go to mobile version