scp is popular protocol and command used to download and upload files and directories in a secure manner. We have all ready examined most of the
scp command features in the following tutorial. In this tutorial we will learn hoe to copy directories or folders recursively with
-r option is used to download or upload files recursively. The copy direction is not important. So for all copy directions recursivity is enabled. It is expressed like below.
$ scp -r
Download Directories Recursively
We will start download directories or folders recursively from remote system to the local system. In this example we will download directories from IP address 172.16.110.35
$ scp -r 172.16.110.135:/home/ismail/test_bak /home/ismail/other
Upload Directories Recursively
In this example we will upload given directory content to the remote system recursively.
$ scp -r Desktop/ 172.16.110.135:/home/ismail/test_bak
Preserve Modification, Access Times and Modes
While uploading and downloading files and directories recursively we may need to preserve the file and directories modification and access times with modes. So we can use
-p option to preserve given attributes.
$ scp -r -p Desktop/ 172.16.110.135:/home/ismail/test_bak
Recursive operations generally transmits a lot of data. We can use the
-C option in order to compress transmitted data. This will made our transfer faster while using less bandwidth.
$ scp -r -C Desktop/ 172.16.110.135:/home/ismail/test_bak