0 Replies Last post: Jan 21, 2012 10:42 AM by Community Admin  
Novice 44 posts since
Mar 30, 2009
Currently Being Moderated

Jan 21, 2012 1:40 PM

Copy files and directories recursively with tar

Copying a directory tree and its contents to another filesystem using tar will preserve ownership, permissions, and timestamps.

 

To copy all of the files and subdirectories in the current working directory to the directory /u01/app/oracle, use:

tar cf - * | ( cd /u02/app/oracle; tar xfp -)

If you receive an error 'filename is greater than 100', write the tarfile with extended headers, like:

tar cEf - * | ( cd /u02/app/oracle; tar xfp -)


The first part of the command before the pipe instruct tar to create an archive of everything in the current directory and write it to standard output (the – in place of a filename frequently indicates stdout). The commands within parentheses cause the shell to change directory to the target directory and untar data from standard input. Since the cd and tar commands are contained within parentheses, their actions are performed together.

 

The -p option in the tar extraction command directs tar to preserve permission and ownership information, if possible given the user executing the command. If you are running the command as superuser, this option is turned on by default and can be omitted.

More Like This

  • Retrieving data ...