Friday, January 23, 2009

Resursive copy of data (with tar/untar method)

I used "cp -pr " method for many years to recusive copy of data from one source to another destination. But, recently I came across some drawbacks of this method and hence shifting to another method. :-)

The main disadvantage of copying bulk data was related to soft links. If the source data has any softlink that points to itself, then this command (cp -pr) can NOT be used. It will fill up the file system fast without complaining.

To overcome linked related problem, here is the new method I am using now:


date; cd /source_directory; tar cvf - * | ( cd /target_directory; tar xvfp -) ; date


If I dont need verbose output, I can use following:

date; cd /source_directory; tar cf - * | ( cd /target_directory; tar xfp -) ; date

1 comment:

Tanweer said...

fantastic and useful :)
1 minor comment * after tar copies all hidden files and directories too..