Bookmark this page

Guided Exercise: Backing Up and Restoring Files From a tar Archive

In this lab, students will create and extract archives with tar.

Outcomes

Students will back up a directory tree and extract the archive content to another location.

  1. Since only the root user can read all the contents of the /etc directory, we are going to back up the directory and log into serverX as root.

    [student@desktopX ~]$ ssh root@serverX
  2. Create an archive of /etc using gzip compression to back up the configuration file directory /etc. Save the file as /tmp/etc.tar.gz.

    [root@serverX ~]# tar czf /tmp/etc.tar.gz /etc
  3. Verify that the backup file etc.tar.gz is a valid archive by decompressing the file to a newly created directory named /backuptest on serverX.

    1. Create the target directory /backuptest.

      [root@serverX ~]# mkdir /backuptest
    2. Switch to the /backuptest directory, where we will extract the files from the etc.tar.gz archive.

      [root@serverX ~]# cd /backuptest
    3. Extract the etc.tar.gz archive to the /backuptest directory.

      [root@serverX backuptest]# tar xzf /tmp/etc.tar.gz
Revision: rh124-7-1b00421