A cp - r issue

I want to copy a folder of size 7g to another destination . It has many other folders and files I use following to do the task

cp -r source   / export/home/source 

But when copy completes so the size on destination is not the same as on earlier location
What is wrong with command?
I'm doing this as root user

Regards

How much different in size is it? Is it larger or smaller?

The thing that immediately comes to mind is links and whether they are copied, or separate files established at the destination. Often 'cp' implements other switches too which provides options as to how links are handled. So in what way is it different?

it is very much smaller then origional one
i have something in /u01/source and want tp copy it another share (SAN) mounted here so the size of source folder is 7.2 GB nut aftter copying, it shows in few Mbs. note that there is an issue going on my /u01 file sysytem and that issue is already under discussion in another thread. issue is that in system messages the error appeared that /u01 file sys is full and after checking through du -sh or du-ah and df-ah it shows 54 GB free space so what i am tryig to do is to copy this source to another SAN share and then delete this so my origional issue might killed so plz advice why is this happening

Are there symlinks in the subdirectories of the source?

What Hicks wanted to say is this:
There is a chance that your default settings will 'skip' (dont follow) symlinks, thus not copied said data, thus resulting in fewer data copied.

Last but not least - and much other than the above...
I'm actualy surprised that you say you have LESS data than expected, because form the following line, I would have expected otherwise:

As this would copy the subdir of current path 'source' and all of the root (/) to the current subdir export/home/source...

no there is no symbolic link but i have stated an issue regarding /u01 ? what is your comments about that why u didin't mention that may be he is palying the nuts role

Because, to my understanding, reading from a full partition should not cause data-loss on the new target that has enough space to write it all.
So I have no idea/thoughts on this.

I understand what and why you are trying to do. I'd be inclined to use old-fashioned commands to see whether you get the same results and/or errors. I'm from a very old school originating before 'cp' supported recursive copying. So why not try this:

Create a target directory (and therefore it would normally be empty). Double check that the target directory pre-exists otherwise the command will fail.
Change directory to the top of the source tree.
Use find piped to cpio commands to copy the whole lot.

As root thus code:

# mkdir <target directory>           <- this must exist before copy starts
# cd <top of source tree>
# find . -print | cpio -puvdm <target directory>

cpio switches explained......

-p = copy from pipe (output of find)
-u = copy unconditionally
-v = be verbose (leave this out to not bury errors within the list of files, easier to see)
-d = allow cpio to create directories as it wants to during the copy
-m = copy across all last modification timestamps to the target

I'd be inclined to see if that gives a different or same result and what errors it might display.

2 Likes

thank you hicksd8

so my source dirrectory is /u01/source and target is /export/home/oracle/source so as per your instructions it would be like following

# cd /u01/source
# find . -print | cpio  -puvdm  /export/home/oracle/source

is it correct as i am confused with "top of source tree " meaning

plz reply

Yes, that is correct. "Top of source tree" is the directory you are in BEFORE you issue the find/cpio copy command.

As I said, the -v in the cpio command will show you all files copied as they are copied. Leave the 'v' out to see only error messages.

You understand correctly. Go for it.

1 Like

Yes I have applied for what you have told me and it doesn’t work definitely your command successfully executed as you have told me but when I saw the size it was just a 28 kB While the size of the source folder is 7.2 GB so I don’t know what is going on why it is not being copied please comment

Wow. Are you sure about this? Go to the target directory and list some files. 28KB is nothing and if you're correct, would only take a few seconds to run (scanning the source but not doing any copying). How are you coming by the 28KB figure??

If you run the command without verbose (no 'v') does it provide error messages?

Compare some file sizes between source and target to see if the sizes are the same, especially larger files.

Also,

Go to the top of the source tree and.....

# find . -print

to list all the files in the tree.

Then, go to the top of the target tree and do the same......

# find . -print

Do you get the same list??

Yes they are same as per your instructions I get exactly the same list so this means they are equal now how I do find the size I apply du - ah so it tells me the size of complete folder whatever in it so that is different but as far as the listing is concerned that is exactly the same thank you for your time please comment

Is /export or /export/home or /export/home/oracle in your target path a mount point?

Perhaps your 28KB is the measure of what's on the parent filesystem only?

Just guessing. What's giving you the 28KB figure?

i used du -sh being in that directory

Agree with you and I found your post very helpful.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.