|Skip Navigation Links|
|Exit Print View|
|Oracle Solaris Administration: Devices and File Systems Oracle Solaris 11 Information Library|
The cpio command is an archiving program that copies a list of files into a single, large output file. This command inserts headers between the individual files to facilitate recovery. You can use the cpio command to copy complete file systems to another slice, another system, or to a media device, such as a tape or USB diskette.
With the cpio command, you frequently use the ls and find commands to list and select the files you want to copy, and then to pipe the output to the cpio command.
# cd filesystem1
# find . -print -depth | cpio -pdm filesystem2
Starts in the current working directory.
Prints the file names.
Descends the directory hierarchy and prints file names from the bottom up.
Creates a list of files.
Creates directories as needed.
Sets the correct modification times on directories.
For more information, see cpio(1).
The files from the directory name you specify are copied. The symbolic links are preserved.
You might also specify the -u option. This option forces an unconditional copy. Otherwise, older files do not replace newer files. This option might be useful if you want an exact copy of a directory, and some of the files being copied might already exist in the target directory.
# cd filesystem2 # ls
# rm -rf filesystem1
Example 20-1 Copying Directories Between File Systems (cpio)
# cd /data1 # find . -print -depth | cpio -pdm /data2 19013 blocks # cd /data2 # ls # rm -rf /data1