cpio Cheat Sheet
http://www.intencorp.com/karmilow/share/howto-cpio.html
Bernie's abbreviated Solaris/Linux cpio How-To
1. Backing up files to a cpio file
cd to the directory you want to archive, and issue the command
solaris-$ find . -depth -print | cpio -ocBdum > filename.cpio
-or-
linux-$ find . -depth -print | cpio -o -H newc > filename.cpio
2. Restoring files from a cpio file
cd to the directory you want the archived files written to, and issue the command
solaris-$ cpio -icBdum < filename.cpio
-or-
linux-$ cpio -idum -H newc < filename.cpio
3. Backing up files to a cpio tape
cd to the directory you want to archive, and issue the command
solaris-$ find . -depth -print | cpio -ocBdum > /dev/rmt/0
-or-
linux-$ find . -depth -print | cpio -o -H newc > /dev/rmt0
4. Restoring files from a cpio tape
cd to the directory you want the archived files written to, and issue the command
solaris-$ cpio -icBdum < /dev/rmt/0
-or-
linux-$ cpio -idum -H newc < /dev/rmt0
5. Restoring a particular file from a cpio tape
cd to the directory you want the archived file (/etc/hosts in this example) written to, and issue the command
solaris-$ cpio -icBdum < /dev/rmt/0 "/etc/hosts"
-or-
linux-$ cpio -idum -H newc < /dev/rmt0 "/etc/hosts"
6. Some other local (Linux) examples
local out:
find etc -depth -print | cpio -o -H newc > cpios/etc.cpio
find include -depth -print | cpio -o -H newc > cpios/include.cpio
local in:
cpio -idum -H newc < /mnt/home/cpios/etc.cpio
cpio -idum -H newc < /mnt/home/cpios/include.cpio
7. Some network (Linux) examples
net out:
pull: remote cpio -> local archive
rsh -n remote_host "cd /remote_dir ; find remote_file -depth -print | cpio -o -H newc" > local_archive
push: local cpio -> remote archive
find local_file -depth -print | cpio -o -H newc -F remote_host:/remote_dir/remote_archive
net in:
pull: remote archive -> local cpio
cpio -idum -H newc -F remote_host:/remote_dir/remote_archive
rsh -n remote_host dd if=/remote_dir/remote_archive | cpio -idum -H newc
push: local archive -> remote cpio
dd if=/local_dir/local_archive | rsh -n remote_host "cd /remote_dir ; cpio -idum -H newc"
Comments
No comments.