Data Loss Prevention   «Prev  Next»

Lesson 4The tar tape backup command
ObjectiveUse the tar command to back up and restore files and directories.

tar Tape Backup Command to restore Files and Directories

The tar command is used to create archives and extract files and directories from tar archives. You can use tar as an expedient and simple method for storing an entire file system. You can then use the tar file as a backup, or you can transfer and extract the file onto another machine. tar is very useful for generating daily backups of critical files (such as a current project) or for archiving data, such as mail for an entire organization.
tar "flattens" files and directories into sequential archives that can go to tape or disk. Linux supports standard commands for tape backup, including:
  1. c: Create an archive
  2. x: Extract files and file systems from a tar archive
  3. z: Use gzip compression
  4. f: Specify the file system on which to store the archive

Pre-Installed Linux Laptop
The following SlideShow illustrates some examples.
  1. Creates an archive using SCSI tape drive
  2. Creates an archive using gzip compression
  3. Extracts from an archive
  4. Extracts from a compressed archive
  5. Places a tar archive onto a file system

Linux tar Commands
Question: What command do you use to create a compressed tar archive named
/project.tar.gz that contains the files and subdirectories in the /project directory?

Answer:
tar czf /project.tar.gz /project
or
tar zcf /project.tar.gz /project

The next lesson examines the use of the dump command.