O'Reilly logo

Unix Backup and Recovery by W. Curtis Preston

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Backing Up and Restoring with the cpio Utility

cpio is a powerful utility, but it makes you do more of the work than dump does. This means you need to know a little bit more about how it works if you want to use it for regular system backups. You need to understand:

  • How to use find with cpio to do full and incremental backups of a filesystem, while leaving the access time (atime) of the files unmodified

  • What arguments give you the best results.

  • How to use rsh to send a cpio backup to a remote backup drive.

  • How to get a table of contents of that volume

  • How to manipulate a tape drive and restore from a backup created by cpio

One good thing about cpio is that its name is usually cpio. (A great advantage over dump to be sure!)

Let’s start with the basic syntax of cpio, followed by some example commands.

cpio’s backup syntax is as follows:

cpio -o [aBcv]

cpio’s restore syntax is as follows:

cpio -i [Btv] [patterns]

The following example command creates a full backup of /home to a local tape drive:

$ cd 
               filesystem
$ touch level.0.cpio.timestamp

The preceding command is optional, but it makes incremental backups possible.

$ find . -print|cpio -oacvB > 
               device

Of course, the device in the preceding command also could be a local file if you are backing up to an optical or CD device. This command creates an incremental backup of /home to a local tape drive:

$ cd /home 
$ touch level.1.cpio.timestamp
$ find . -newer level.0.cpio.timestamp -print \
                 |cpio -oacvB > device

This command creates a full backup ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required