4

We are using ubuntu server, and I have to move folders from one server to another server:

Folders: /var/www/html/demo5/site/app to /var/www/html/1/10/site
(Where app is the folder name)

Hostnames: 123.123 to host 456.456

Usernames: abc to username : xyz

I have SSH access, but I am new to these commands.

I have already tried this link, but I didn't get it to work as I am new to commands.

4 Answers4

5

To copy files from a local machine to a remote machine, do something like this:

rsync -avz --delete /path/to/local/dir/ remote_user@remote_host:/path/to/destination/dir

(Notice that the command uses a trailing slash in /path/to/local/dir/, which you DO NOT need in /path/to/destination/dir)

After you've verified that everything worked correctly, delete the source files if you don't need them anymore.

If you don't have rsync installed, install it first with:

sudo apt-get install rsync

Rsync is the right tool for the job. It is very robust, can efficiently continue an interrupted copy job, and the command above will preserve the file attributes and permissions. To additionally preserve hard links, ACLs, and extended attributes, use rsync -aHAXvz.

A.P.
  • 416
1

You can use secure copy (scp) :

  1. Connect to your 123.123 host with ssh.
  2. From here run :

     scp -r /var/www/html/demo5/site/app xyz@456.456:/var/www/html/1/10/site
    
  3. (Optional) If you want a move,not a copy, delete the folder :

     rm -r /var/www/html/demo5/site/app
    

Refer to rcp man page for more information.

hg8
  • 13,462
1

You probably just have to SSH to the first one beforehand - so after running ssh abc@123.123 (with actual username and IP address), you could run something like one of these (you probably shouldn't do both):

scp -r /var/www/html/demo5/site/app xyx@456.456:/var/www/html/1/10/site
rsync -auv -e ssh --progress /var/www/html/demo5/site/app xyx@456.456:/var/www/html/1/10/site

Note that this will likely copy files. Before running any commands I would recommend backing up your current setup in case anything goes wrong.

If you want more information, you can read the manual pages of various commands using the man command - e.g. man scp, man rsync. I would also recommend looking at what options you are using before doing anything.

N.B. Not sure but it may be easier to have one server redirect requests to the other if you just want both servers to show the same thing, unless of course you need multiple copies available.

Wilf
  • 30,194
  • 17
  • 108
  • 164
1

If you have ssh access you could use scp command.

scp -r abc@123.123:/var/www/html/demo5/site/app zyz@456.456:/var/www/html/1/10/site

I get this information from here: http://www.hypexr.org/linux_scp_help.php

migrc
  • 416