scp -rp does not preserve attributes
I am trying to copy an entire remote directory. I want to preserve at least modification times:
scp -P229 -rp user@10.0.3.1:/path/to/directory ./ I've done this before and it used to work. Now, the files are all transferred with the current time and date. What am I doing wrong? |
Not sure, that p should do the job. But I'm far from expert on scp. Have you thought on using something else to copy those files? It is not that scp is really efficient in copping large number of files, it kinda has to establish contact for every file separately, which sure slows things down. You might have more luck in using rsync, or even tar over ssh. For example from machine where files you want to copy are:
Code:
tar zcf - /things/to/copy | ssh user@adress 'tar zxf -' Code:
ssh user@adress 'tar zcf - /things/to/copy/' | tar zxf - |
Have you tried it the other way round? First ssh into 10.0.3.1 and copy it from there using scp -pr.
|
SCP is not the best option for copying directories. It has also problems with directory names containing spaces.
Use rsync. It never fails. Note however that if you try to copy files which have a different owner on the remote computer they will be owned by you on your local computer. If that is not the intention, issue the command as root. So you will write files on your local machine which root permissions. In your example, the correct rsync command would be: Code:
rsync -av --port=229 user@10.0.3.1:/path/to/directory/ ./ The -a option will recursively copy the source directory, maintaining permissions and file creation times. There are a hundred more options to add to rsync. Check the man page if you need something more exotic. jlinkels |
All times are GMT -5. The time now is 07:37 PM. |