Bookmark this page

Guided Exercise: Synchronizing Two Directories Securely With rsync

In this lab, students will synchronize a folder with a remote system by using rsync.

Outcomes

A directory will be synchronized from a remote machine to the local machine. After files on the remote machine have changed, it will be synchronized with the local machine again and only the modifications will be transferred. Both systems will end with identical content in the directories synchronized with rsync.

  1. Securely create an initial copy of the /var/log directory tree on serverX to a newly created directory named /serverlogs on desktopX with the rsync command.

    1. In order to create the target directory /serverlogs, switch to the root user account with the su command.

      [student@desktopX ~]$ su -
      Password: redhat
      [root@desktopX ~]# 
    2. Create the target directory /serverlogs on desktopX where the log files of serverX will be synchronized.

      [root@desktopX ~]# mkdir /serverlogs
    3. Use the rsync command to synchronize the /var/log directory tree on serverX to the /serverlogs directory on desktopX. Note that only the root user can read all the content in the /var/log directory on serverX. All files will be transferred in the initial synchronization.

      [root@desktopX ~]# rsync -av root@serverX:/var/log /serverlogs
      ...
  2. As root on serverX, run logger "Log files synchronized" to get a new entry in the log file /var/log/messages to reflect when the last synchronization took place.

    [root@desktopX ~]# ssh root@serverX 'logger "Log files synchronized"'
    Password: redhat
    [root@desktopX ~]# 
  3. Securely synchronize the /var/log directory tree on serverX to the /serverlogs directory on desktopX with the rsync command again. Note that this time only the changed log file(s) will be transferred.

    [root@desktopX ~]# rsync -av root@serverX:/var/log /serverlogs
    ...
Revision: rh124-7-1b00421