Next | Prev | Up | Top | Contents | Index
Saving Data With cpio
This section describes how to back up files with the cpio command, and how you can back up files that have been modified since a certain specific time, or relative to the last backup (incrementally).
Backing Up Files With cpio
To back up files with cpio, use the command:
cat filelist | cpio -o > /dev/tape
Saving Files by Modification Date
The cpio command does not have the capability of saving files by modification date built in. However, you can use the find command to archive files that have not been modified in a particular number of days:
find /usr -mtime 5 -depth -print | cpio -oO /dev/tape
The -depth argument causes find to print the name of the directory after printing the files in that directory. This ensures that cpio has permission to place the files in the directory in case the directory is read-only.
Incremental Backups With cpio
Although tar and cpio do not have built-in mechanisms for incremental backups, you can use other system commands to accomplish this task.
The following example uses the same incremental scheme presented in the preceding section to back up the /usr filesystem. It uses the find command to determine which files to archive:
- Go to the top of the filesystem that you want to back up. For example:
cd /usr
- Create a complete backup of the filesystem:
cpio -oLp .
- Each day, back up the files that have changed since the previous daily backup:
find /usr -mtime 1 -print | cpio -pdL
- Every week, back up the files that have changed since the last weekly backup:
find /usr -mtime 7 -type f -print | cpio -pdL
- At the end of four weeks, perform a complete backup and start the process over.
Next | Prev | Up | Top | Contents | Index