When uploading your website to new server or migrating a website to different server then you are require to copy some file from one machine to another. There are various ways to do this like web-base uploading and FTP etc. But in this article I will introduce you with two more Linux command to copy files between two Linux server. Which are more powerful then ftp.
Linux has two built in command to copy files between Linux system over ssh.
rsync is more powerful than scp because it has options to compress data while transfer and has ability to resume previously interrupted/broken transfer. To use these command you need ssh access to remote machine.
Commands to copy files/directory via scp
copy remote files to local
1
|
scp user@remotehost: /source_path /destination_path |
To copy whole directory use following command
1
|
scp -r user@remotehost: /source_path /destination_path |
Where -r means recursively.
To copy local files to remote machine
1
|
scp /source_path user@remotehost: /destination_path |
Above commans will overwrite files in destination_path if file already exist.
Commands to copy files/directory via rsync
copy remote files to local
1
|
rsync -chavzP user@remotehost: /source_path /destination_path |
To copy local files to remote machine
1
|
rsync -chavzP /source_path user@remotehost: /destination_path |
Read more about rsync and check all available options.