4
I am trying to copy changed files to godaddy via ssh. Godaddy is terrible and so they of course do not allow rsync. I can use scp, but I really only want to copy changed files. I don't think this is possible, so I was wondering if perhaps I could scp only all php files.
There are a lot of sub directories, though, so I need to use the -r option.
Is there a way I can use scp to copy all files with extension php
, recursively? like this:
scp -r -name "*php" /local/html/ user@server:/home/html/
(does not work)
DESIRED RESULT
//on local machine $ find ./source source/1.php source/2.php source/sub source/sub/3.php source/sub/4.php source/sub/DONT-copy.txt source/sub/DONT-copy.png source/sub/sub2 source/sub/sub2/5.php source/sub/sub2/6.php //command to copy the files $ [scp command here] //on remote server $ find ./destination destination/1.php destination/2.php destination/sub destination/sub/3.php destination/sub/4.php destination/sub/sub2 destination/sub/sub2/5.php destination/sub/sub2/6.php
THIS DOES NOT WORK
//on local machine $ find ./source source/1.php source/2.php source/sub source/sub/3.php source/sub/4.php source/sub/DONT-copy.txt source/sub/DONT-copy.png source/sub/sub2 source/sub/sub2/5.php source/sub/sub2/6.php //command to copy the files $ cd source; scp -r *.php user@remote:/destination //on remote server $ find ./destination destination/1.php destination/2.php
Perhaps we could try and use find, as well, but I'm pretty sure this will not work as is:
find ./source -name "*.php" -exec scp {} user@remote:{} \;
That won't work because I don't think you can use multiple {}
operators in find.
Also, it might be tricky to get the paths to line up on the remote server, for example if find was returning /users/johndoe/documents/source/1.php
and you wanted it to end up at /home/jane/www/destination/1.php
on the remote server.
2Is it possible that you run a command (via ssh) on the remote server? If so, you can tar the files locally and do a
cat phpfiles.tar | ssh user@remote "cd destination && tar cf -"
to transfer all you files in one run. – mpy – 2013-03-16T17:18:29.473Did you actually tried your last find command with multiple
{}
tokens? I looks promising (you can use multiple{}
), perhaps you need to specifyuser@remote:~/{}
as destination. – mpy – 2013-03-16T17:20:06.120Oups, this question was nearly two year ago... I am wondering why it showed on top of the questions rigth now... – mpy – 2013-03-16T17:23:14.193