Monday, May 8, 2017

Copy folder from local to remote or vice versa

Option 1: scp -r
To copy all from Local Location to Remote Location (Upload)
scp -r /path/to/file username@hostname:/path/to/destination

To copy all from Remote Location to Local Location (Download)
scp -r username@hostname:/path/to/file /path/to/destination

Custom Port where xxxx is custom port number
scp -r -p xxxx username@hostname:/path/to/file /path/to/destination

Copy on current directory from Remote to Local
scp -r username@hostname:/path/to/file .


Option 2: zip to file then scp
Better to first compress catalog on remote server:
tar czfP backup.tar.gz /path/to/catalog

Secondly, download from remote:
scp user@your.server.example.com:/path/to/backup.tar.gz .

At the end, extract the files:
tar -xzvf backup.tar.gz

Option 3: sftp
$ sftp user_remote@remote_ip
sftp> cd /path/to/remoteDir
sftp> get -r remoteDir

No comments:

Post a Comment