| Subcribe via RSS

scp server to server

February 6th, 2008 Posted in server by dreamluverz


SOURCE: http://forums.serverbeach.com/archive/index.php/t-2202.html

I’ve been looking for this reference and finally found it. Thanks for them who posted it on the link above. :) I’ll be trying this out :)

Let’s begin and assume the following information:
Server A is our host where the original files are located.
Server B is where we need to copy files to.

1. Make sure on Server A you have enabled Shell access for the user account you are going to use. Let’s say our files are in /home/user1/public_html/myfiles. In this case, make sure you enable user1 shell access.

2. Login SSH on Server B, login as root “su”, or as user1 should work too so long as you stick the files in the same place.

3. Type this command:
where xx.xx.xx.xx is the IP address of Server A

scp -rv user1@xx.xx.xx.xx:/home/user1/public_html/myfiles/ /home/user1/public_html/myfiles/

notice there is a *SPACE* after /myfile/ and /home/

You will be prompted for the SSH password of user1 at Server A. Enter this, and the copy process will start.

the -r option copies everything in the directory tree.
/home/user1/public_html/myfiles/dir1/
/home/user1/public_html/myfiles/dir2/
/home/user1/public_html/myfiles/dir3/moredir1/
etc…..



the -v option is verbose, lets you see the transfer in action in your ssh terminal.

==========================

scp with -p options is better
scp -prv user1@xx.xx.xx.xx:/home/user1/public_html/myfiles/ /home/user1/public_html/myfiles/

the -p option Preserves modification times, access times, and modes from the original file

6 Responses to “scp server to server”

  1. dreamluverz Says:

    I’ve tried it and it worked. Makes life easier than manually copying it. really helps!!!


  2. dreamluverz Says:

    btw, regarding the usage of the -p option I suggest not to use it coz in doing this I got prob with the ownership & permission of the dir/files. I haven’t carefully read the description of it that it also preserves the mode. That’s why as you can see on this post I was looking for reference on how to change ownershp/permission.

    Luckily it was solved. :)


  3. dreamluverz Says:

    but seems like I still got some error on smarty
    ———
    Fatal error: Smarty error: unable to write to $compile_dir ‘/home/lacartes/public_html/links/templates_c’. Be sure $compile_dir is writable by the web server user. in /home/lacartes/public_html/links/libs/Smarty.class.php on line 1095
    —-

    coz one particular site uses smarty. But already changed the mode of it but still got that error. so now I deleted that folder and copied it again from the original server with out the -p option :P wish me luck :)


  4. dreamluverz Says:

    well I found out it has nothing to do with it I guess..


  5. dreamluverz Says:

    as what i’ve said i got an error with smarty:

    “Smarty error: unable to write to $compile_dir”

    Accdg. to some forum change the permission to 777 so i did. and it works! tnx so much

    chmod -R -v 777 [path]/templates_c

    With regards to the ownership I mentioned earlier, I don’t know why either i use the option -p on scp I still got the ownership permissions.


  6. dreamluverz Says:

    and for moving of files you can do:
    mv -v [source_path] [destination_path]

    notice that on the options there’s no ‘r’ coz it’s not applicable.


Leave a Reply