Bookmark this page

Lab: Archiving and Copying Files Between Systems

Performance Checklist

In this lab, students will use rsync, scp, and tar to archive and back up folder contents.

Outcomes

Students will synchronize a remote folder to a local directory; an archive is then created with the synchronized folder as content; the archive gets copied to the remote machine and extracted to a newly created directory.

Reset your serverX system.

  1. Synchronize the /etc directory tree on serverX to the /configsync directory on desktopX.

    1. To be able to create the target directory /configsync, switch to the root user account using su.

      [student@desktopX ~]$ su -
      Password: redhat
      [root@desktopX ~]# 
    2. Create the target directory for the configuration files on desktopX.

      [root@desktopX ~]# mkdir /configsync
    3. Use the rsync command to synchronize the /etc directory tree on serverX to the /configsync directory on desktopX. Be aware that only the root user can read all the content in the /etc directory on serverX.

      [root@desktopX ~]# rsync -av root@serverX:/etc /configsync
      ...
  2. On desktopX, create an archive named /root/configfile-backup-serverX.tar.gz with the /configsync directory as content, and copy the archive to the /root directory on serverX for backup purposes with the scp command.

    1. Store the /configsync directory in the /root/configfile-backup-serverX.tar.gz archive.

      [root@desktopX ~]# tar czf /root/configfile-backup-serverX.tar.gz /configsync
    2. Create a backup copy of the /root/configfile-backup-serverX.tar.gz on serverX

      [root@desktopX configsync]# scp /root/configfile-backup-serverX.tar.gz root@serverX:/root
      Password: redhat
      ...
  3. To prepare the archived directory tree for comparison with the currently actively used configuration files on serverX, extract the contents of the /root/configfile-backup-serverX.tar.gz archive to the /tmp/savedconfig/ directory on serverX.

    1. Connect to the serverX machine as root by using ssh.

      [root@desktopX configsync]# ssh root@serverX
      Password: redhat
      [root@serverX ~]# 
    2. Create the target directory /tmp/savedconfig/, where the contents of the /root/configfile-backup-serverX.tar.gz archive will be extracted.

      [root@serverX ~]# mkdir /tmp/savedconfig
    3. Change to the target directory /tmp/savedconfig/ on serverX.

      [root@serverX ~]# cd /tmp/savedconfig
      [root@serverX savedconfig]# 
    4. Extract the contents of the /root/configfile-backup-serverX.tar.gz archive to the /tmp/savedconfig/ directory on serverX.

      [root@serverX savedconfig]# tar xzf /root/configfile-backup-serverX.tar.gz
Revision: rh124-7-1b00421