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!

Related Posts

A compact server with connected Ethernet cables and illuminated network ports in a dark server room.

Fix Debian 13’s 120-Second systemd-networkd Boot Delay

A boot pause close to two minutes can occur when systemd-networkd-wait-online.service cannot satisfy its definition of an online network. The systemd 257 documentation specifies a default timeout…

introduction to openmediavault

Introducing OpenMediaVault: Your Ultimate Guide

Want to create a home server setup without spending a lot? OpenMediaVault is a free NAS solution that makes network attached storage easy. It’s great for saving…

Using rsync for One-Way Sync for backup

If you’re looking to set up a one-way sync between a NAS running Debian and a backup machine also running Debian, rsync is a powerful tool to achieve this….

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…

Leave a Reply