Copy files recursively with directory structure from source server to Target server

I am trying to copy the files modified from specific date to current date from Source server to target server with same directory structure. I have created the script for copying files from Source directory to target directory in same server. Now looking for 2 different Linux servers.

Source server: Source34.abc.net

Directory and files: /home/Amal/db/tmp/File1.txt, /home/Amal/db/work/File2.txt, /home/Amal/db/out.xml

Target Server: Target30.efg.net

Directory : /home/Amal/db/tmp/ /home/Amal/db/work/

Want to achieve:

  1. Sftp from source server to Target server
  2. Copy the files from source to Target with the same folder structure

NOTE: Source and Target will have same Directory structure

5

1 Answer

Probably the most easiest way to use scp through ssh.

Open terminal in source system and type in the command below

scp <source-directory> -i <path-to-ssh-key> <ipaddress-of-target>@<user>:<target-directory>

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like