Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Labs  RHEL Backup and Restore Assistant

RHEL Backup and Restore Assistant


Knowledge Type

Choose tool

 Tool tar and cpio

Backup with tar and cpio

Both the tar and cpio commands are used to archive files and folders, and are
commonly used by Linux system administrators to backup tape drives.

Backup with command tar


The tar command is the most commonly used way to create compressed
archive files and to back up files and folders.

# tar [ -option ] -cf target_backup_file source

The following are examples of backing up the root file system:

1. Backup / to a new created folder /backupdata

# tar --exclude=/proc,/mnt,/tmp,/backupdata -cvpjf /backupdata/sys

2. Backup / to a file below root


# tar --exclude=/proc,/mnt,/sys,/backup.tar.gz -cvpzf backup.tar.g

3. Backup / to the partition to a SCSI device st0

# tar --exclude=/proc,/sys,/dev -cvpzf /dev/st0 /

Backup with command cpio


The cpio command copies files into or out of a cpio or tar archive. This archive
can be another file on the disk, a magnetic tape, or a pipe.

The syntax for the cpio command is:

# cpio -ovcB > [file|device]

1. An example of backup with cpio

This example illustrates how to backup operations to the /boot folder.


The find command is widely used in with cpio to locate files.

# find /boot | cpio -ocvB > /tmp/boot.cpio

Restore with tar and cpio

Restore from archive file with command tar

The syntax for the tar command to restore files is:

# tar [ -option ] -xf backup_file

1. The following examples illustrate how to restore files with the tar command:

The default location for the backup tar file is /backupdata/system.tar.bz2.


Switch to the root user to access this file location.
# tar -xvpjf /backupdata/system.tar.bz2 /

Restore from archive file with command cpio

The syntax for the cpio command used to restore files is:

# cpio -ivcdu < [file|device]

1. The following are two examples of restoring files with the cpio command:

Restoring from a SCSI device st0 to current working folder:

# cpio -iduv < /dev/st0

2. Restoring from a local file /tmp/boot.cpio to current working folder:

# cpio -idvc < /tmp/boot.cpio

BACK

Copyright © 2021 Red Hat, Inc.

You might also like