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 ...
Get Unix Backup and Recovery now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.