Exercise
Synchronizing Directories with rsync Exercise
Task
In this hands-on exercise, synchronize
servera's log directory into
/tmp, generate changes, and compare the
first and second transfers.
- Local host
-
workstation - Remote host
-
servera - Privileges
sudoaccess on both hosts
-
Install rsync on both machines
rsyncmust be present on both ends of the transfer, and it is not part of a minimal installation.sudo dnf install -y rsync ssh student@servera sudo dnf install -y rsync exit -
Preview and run the first synchronization
-nis a dry run: it reports what would move and changes nothing.-ais archive mode and-vnames each file as it goes.rsync -avn root@servera:/var/log /tmpThe first pass copies everything, exactly as
scpwould. Note the byte counts printed at the end.rsync -av root@servera:/var/log /tmp -
Generate changes and synchronize again
loggerwrites a message into the system log.ssh root@servera logger -t rsync-exercise "Generating a new log entry for the transfer exercise" logger -t rsync-exercise "And one more" tail -n 2 /var/log/messages exitRun exactly the same command again and compare the byte counts with the first run.
rsync -av root@servera:/var/log /tmp -
Verify the changes and clean up
Search your local copy for the messages you generated.
grep 'rsync-exercise' /tmp/log/messagesRemove the local copy of the log directory.
sudo rm -rf /tmp/log ls /tmp