Problem solve Get help with specific problems with your technologies, process and projects.

Copying entire directories in UNIX

To copy an entire directory including links and properties (snap-shot), use the find command in conjunction with cpio.

Here's an example for copying all of /usr to /backup-usr (must be root to do this example):

#cd /usr
#find . -print | cpio -pduvm /backup-usr

Then, you can rename the /backup-usr to /usr and you will have no problems with links or system permissions.

About the author: Greg Hearn is a UNIX Systems Administrator at LVVWD.

Editor's Note: We provide user-submitted tips as a service to our members to help foster other comments and advice. This tip has not been checked in detail for its technical accuracy. Instead, we rely on our community members to police themselves via our tip rating system and by sending in follow-up comments to about a specific tip or tip author. We appreciate your help in making searchStorage a more successful and collaborative community of storage professionals.

This was last published in February 2001

Dig Deeper on Data storage strategy

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.