cpio 

Send to Kindle
home » snippets » linux » cpio



Command line options

Quickly cloning a tree picking out just a subset of files.

From: http://fixunix.com/sco/89900-cpio-performance-vs-tar-bit-mystery.html#post296008

I'd used -pdlmv - and you can only use -l with the -p.

It creates hard links. The new directory is the only thing that is created. Files stay in their same location so it's blazingly fast.

Then you go and remove the original directories.

This only works on systems that support hard links and obviously that means you can't cross filesystem boundaries.

Gotchas

bad timestamp on directories using cpio

re: bad timestamp on directories using cpio; I think you can fix that by adding -depth as a find option. Without -depth, the directory gets restored first, then its timestamp is updated as you restore files into it. With -depth, the files are presented by find before the directory itself, so cpio will create the directory w/ default settings so it can restore the file. Once all restores are done into that directory, find will present the directory itself so the original dir owner, group, perms, and timestamps will be restored.