Copying files using ssh

Discussion in 'Site & Server Administration' started by PinoyIto, Jul 6, 2006.

  1. #1
    I need to move files from my old server to new server.... how to copy all the content of a particular folder example pictures from my old server to my new server at the same folder pictures.
     
    PinoyIto, Jul 6, 2006 IP
  2. hans

    hans Well-Known Member

    Messages:
    2,923
    Likes Received:
    126
    Best Answers:
    1
    Trophy Points:
    173
    #2
    assuming that you have Linux
    use rsync

    it works on both directions - means
    on any of th eserver you are logged in via SSH
    on both servers you have your password or access data of ocurse

    then you pull or push all files you want directly from server to server

    i also use the same rsync tool to backup my forums
    and earlier to back up the entire site to another server

    if you need detailed syntax - just tell me an di give a full command line example if rsync is aon optikon for your linux enviroment
     
    hans, Jul 6, 2006 IP
  3. PinoyIto

    PinoyIto Notable Member

    Messages:
    5,863
    Likes Received:
    170
    Best Answers:
    0
    Trophy Points:
    260
    #3
    Please tell me how can I use that in cpanel ssh tool. Can you give me a sample command text to that.
     
    PinoyIto, Jul 6, 2006 IP
  4. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,334
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #4
    If it's a one-time copy, you probably want to use scp (secure copy)...

    scp sourcefolder user@host:path
     
    digitalpoint, Jul 7, 2006 IP
  5. hans

    hans Well-Known Member

    Messages:
    2,923
    Likes Received:
    126
    Best Answers:
    1
    Trophy Points:
    173
    #5
    i have no knowledge about cpanel
    i do all directly on my laptop using direct ssh connection with bash on SuSE/Novell Linux

    but if you have a regular shell in cpanel for ssh connection then the syntax and possibilities might be exactly the same

    hence here my syntax

    local machine can be the NEW server/host where you first login to execute the same command line
    local machine in MY case is my laptop where i use exactly same procedure to backup some forum directories

    ------- syntax start - ALL ONE line !!!
    
    rsync -pavz --progress username@your_remote_site.com:/your_path/to_your_public_directory/your_path_on_your_server_to_the_folder_to_back-up/* /the_local_path_to_the_folder/where_you_want_to_store/the_back_up_data
    
    Code (markup):
    ------- syntax end

    you will now be promted for password

    if above SSH for some reason is disabled on your host
    then try scp with below syntax

    below copies from local machine to remote machine:

    ------- syntax start - ALL ONE line !!!
    
    scp /the_local_path_to_the_folder/where_you_have_the_folder/to_be_transfered/* username@your_remote_site.com:/your_path/to_your_public_directory_on_remote_site/to_the_folder_to_store_data
    
    Code (markup):
    ------- syntax end


    another solution is wget

    login at the receivers ( NEW ) host via telnet or SSH in your shell
    then execture the wget command as needed
    you need regulr full URL - that means the data need to be remotely in public folders accessible !!

    1.
    create on the NEW ( receivers ) site a folder
    2.
    cd to that folder
    check with pwd !!! to assure you are in that folder
    3.
    then execute wget ( this one is NON-secure - hence it also works on regular ftp accounts withotu SSH access on remote host!

    ------- syntax start - ALL ONE line !!!
    
    wget --ftp-user=your_username --ftp-password=your_ftp_password_for_remote_machne_here -r -m -np http://www.your_remote_old_host.com/the_subfolder/you_wish_to_trasnfert/
    
    Code (markup):
    ------- syntax start - ALL ONE line !!!

    above does require that you have index enabled in your remote .htaccess file else you get an error - like:
    HTTP request sent, awaiting response... 403 Forbidden
    16:34:21 ERROR 403: Forbidden.

    in addition to all 3 a.m. solutions
    there are other solutions

    Linux has solutions
    XP creates problems

    what is your choice in life ?

    you still did not mention what OS you have locally

    for much more you may either call my cp or just drop by - may be you are next door to my location in the PH - presently La Union later Boracay for a while
     
    hans, Jul 7, 2006 IP
  6. wheel

    wheel Peon

    Messages:
    477
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #6
    that's what I would use as well. To clarify: the text would look like:
    scp file-you-want-to-copy :/path/to/your/site

    replacing 'file-you-want-to-copy' with the folder on your old site, replace useranme-at-new-site with your new username, replace XXX.XXX.XXX.XXX with the ip address of your new site. You'd run this command from your old server.

    i.e.
    scp /myoldwebsite bobsmith@99.99.99.99:/public_html

    rsync is great and has some fabulous features, but all the options make it a bit confusing for a one time copy.
     
    wheel, Jul 7, 2006 IP
  7. theblight

    theblight Peon

    Messages:
    246
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #7
    you can also use the code below to maintain the permisions
    'scp -rp <folder-name> user@destination-ip:/location/of/the/destination' 
    Code (markup):
    Hope it Helps
     
    theblight, Jul 8, 2006 IP