SCP copy directories

SCP copy directories

SCP copy directories – How to use.
Previously i posted an article on how to use SCP to download or upload files. You can find that here http://soltveit.org/linux-scp-to-download-or-upload-files/

That only goes for files, and not directories. How you copy whole directories is very similar. You just need and extra parameter to the SCP command. Add the -rp parameter to your SCP command.

SCP Copy directories usage:
scp -rp sourcedirectory user@dest:/path

What the parameters means:
-r recursive
-p preserves modification times, access times, and modes from the original file

SCP Copy directories example #1
Lets copy a directory from our local system to a remote system.
scp -rp photos john@192.168.1.80:/home/john/mybackup

The above command copy the local directory photos and uploads it to a remote system inside Johns mybackup folder. Existing files and folders will be overwritten with this method. Only if they have the same folder and filenames of course.

SCP Copy directories example #2
In this example we will download a folder from a remote system to our local system. Using the SCP command to download the entire folder and sub-folders if there are any.
scp -rp john@192.168.1.80:/home/john/photos mybackup

This command will download Johns photo folder and save it inside our mybackup folder on our local system.

If you want to read more about the SCP command, check out the Linux man page about SCP here http://linux.die.net/man/1/scp

One last tip

There is another parameter you can use to save time and bandwidth.
-C Compress on the fly. Note this is a capital C.
This will compress the files on the fly, send the files compressed and decompress them on the remote system. For large data amount I would give it a try to see how it perform compared to a uncompressed data transfer.

Thats all I had for copying directories with SCP.

Happy copying!

About Author

Related Posts

php8 gd

PHP8 gd Activate after installation

PHP8 GD activate after installation. GD doesn’t get activated by default. Not even a reboot after installation will activate it. So how do we do it? In…

Debian 12: linux-image-6.1.0-10amd64

Troubleshooting dependency issues in Debian 12: Resolving linux-image-6.1.0-10amd64 package dependency problems. If you installed the Debian 12 from the live image the issue is the raspi-firmware. Even…

4 Best Free Nas Software That Is Open Source

Free NAS software or operating systems that are free to use and will turn a computer into a NAS more advanced than the dedicated boxes sold. What…

Raspbian default password

Raspbian default password

Looking for the Raspbian default password? It is the most essential username and password that you will need for your raspberry. At least if you are running…

OpenMediaVault default password

OpenMediaVault default password

OpenMediaVault default password is printed in the documentation. I did not see it the first time I installed it either. So I had to do some detective…

Debian change dns

Debian change DNS settings to a new DNS

Debian change DNS settings for speed improvement or privacy. It is really easy to do. So let us see how it’s done and get to it. The…

Leave a Reply