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.

link|improve this question

feedback

migrated from stackoverflow.com Aug 23 '11 at 1:44

This question came from our site for professional and enthusiast programmers.

1 Answer

Can you not do scp -r *.php destination ?

link|improve this answer
but will that copy all *.php files in subdirectories as well? – cwd Aug 16 '11 at 21:15
@cwd: What is your exact requirement? – hari Aug 17 '11 at 21:18
updated the question – cwd Aug 18 '11 at 3:18
I am still not sure what you are asking here. what files you want to copy from /local/html? all *.php files? only changed *.php files? what does argument -name mean? – hari Aug 18 '11 at 5:08
-name is the paramater that rsync uses to filter only php files. i would ideally like to copy only changed files (like rsync) but since rsync is not available I would like to just copy php files only (to save bandwidth). Does that make sense? I guess I could do a find -exec scp command but I would need to grab the basepath and make sure that gets added to the destination argument as well. just seems like there should be an easy way to do it. – cwd Aug 19 '11 at 3:07
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.