Distributed Systems LAB - 4
By : A Charan Sai Tej
Reg No : 22BCE7478
Slot : L4 - L5 vavwVE
TASK: Time Synchronization and Automated Backups
Configure a UNIX system to keep the local time accurate within the range of a single second.
Likewise, configure an automatic backup facility by which a number of crucial files are
automatically transferred to a remote machine once every 5 minutes. The solution should be
efficient when it comes to bandwidth usage.
Introduction
This document details the process of configuring an Ubuntu system for two critical tasks. First,
the Chrony utility is used to synchronize the system clock with Network Time Protocol (NTP)
servers for high accuracy. Second, an automated, bandwidth-efficient backup system is
established using rsync and cron to transfer files to a remote location every five minutes.
Part 1: Time Synchronization with Chrony
● Installation: The chrony package was installed using the apt package manager.
○ sudo apt update
○ sudo apt install chrony
● Configuration: The main configuration file was edited to point to a reliable pool of time
servers.
○ File: /etc/chrony/[Link]
○ Configuration: The pool directive was set to [Link] with the iburst
option for faster initial synchronization.
● Service Management: The chrony service was started and enabled to ensure it runs
automatically on system boot. The correct service name chrony was used.
○ sudo systemctl start chrony
○ sudo systemctl enable chrony
● Verification: The chronyc tracking command was used to verify the
synchronization status. The output confirmed that the System time was accurate to
within a few milliseconds of the NTP time, satisfying the one-second accuracy
requirement.
● Part 2: Automated Backup Facility
● Prerequisite: Passwordless SSH Setup: To allow the automated script to connect to a
server without a password prompt, SSH key-based authentication was configured. For
this lab, the process was tested by connecting the machine to itself (localhost).
○ SSH Server Installation: The openssh-server package was installed to allow
the machine to accept SSH connections.(sudo apt install
openssh-server)
○ Key Generation: An RSA 4096-bit SSH key pair was generated using the default
file path (~/.ssh/id_rsa).(ssh-keygen -t rsa -b 4096)
○ Key Distribution: The public key was copied to the local machine's authorized
keys file.(ssh-copy-id charan-chotu@localhost)
○ Verification: A successful passwordless login was confirmed by running ssh
charan-chotu@localhost.
● Backup Script and Scheduling with Cron:
○ Tool Selection: rsync was chosen for its bandwidth efficiency, as its
delta-transfer algorithm only sends file differences.
○ Test Directories: Sample source (~/crucial_files) and destination
(~/backups) directories were created for the test.
○ Scheduling: The crontab -e command was used to open the user's crontab
and schedule the backup job.
● Crontab Entry: The following line was added to run the backup every five minutes:
Code snippet
*/5 * * * * rsync -az --delete ~/crucial_files/ ~/backups/ > /dev/null 2>&1
● Verification of Automated Backup:
○ After waiting for five minutes for the cron job to execute, the contents of the
destination directory were checked.
○ The command ls -l ~/backups confirmed that the sample files from
~/crucial_files had been successfully copied, proving the automated
system was working correctly.