Results 1 to 6 of 6
Hi !
I have to copy /usr directory from one drive to another. I tried to copy it with cp,but failed. Then people told me to use "tar". Then I ...
- 04-29-2009 #1Just Joined!
- Join Date
- Apr 2009
- Posts
- 63
tar not working in this case
Hi !
I have to copy /usr directory from one drive to another. I tried to copy it with cp,but failed. Then people told me to use "tar". Then I made " tar -cvf ....." of /usr directory and moved it to the target drive by "mv".Then I tried to "tar -xvf ....." there. But I got a very big list of errors like " /usr/include/....something.... no such file or directory. I am using SuSE 11.0
How to copy /usr correctly?
- 04-29-2009 #2
Did you use the recursive flag with cp?
Code:cp -r /usr /destination/directory
- 04-30-2009 #3Just Joined!
- Join Date
- Apr 2009
- Posts
- 63
No, I did not use "cp -r ....." I used " cp ....." and "cp -dpR ....." Now I will use cp -r and see what happens.
- 04-30-2009 #4
You really should use 'cp -a ...' for tasks like this - it does the recursive thing and also preserves user permissions and ownership (-a wraps up a series of other flags for cp).
Linux user #126863 - see http://linuxcounter.net/
- 04-30-2009 #5Linux Newbie
- Join Date
- Mar 2009
- Posts
- 228
This is how I've used tar to copy a directory structure to a new location:
Code:cd /usr; tar -cf - . | ( cd /path/to/target; tar -xf - )
- 04-30-2009 #6Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513
We need to know the exact (and by exact I mean "letter by letter") command that you used and what results did you get. Otherwise we have no idea about what your problem might be.
In any case, two things are important when doing this task: you need to preserver ownserships/permissions and you have to copy recursively the whole tree. How to do that: it depends on the tools you use.
If you are going to use tar, make sure you use -p, the rest of the flags you use depends on whether you want compression, verbosity or whatever else. For example, to /usr into a file using gz compression and verbosity while preserving permissions you would do
If you want to use cp you can use either "cp -a" or "cp -dpR" (or -dpr, both cases work for the 'r'). -a almost equals -dpR (but not exactly, depending on the underlying file system anyway).Code:tar -cvjpf <backup_file> /usr


Reply With Quote