Score:0

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

ma flag

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

uz flag
Jos
Do you only have `sftp` access to both servers? This could be easily accomplished with `ssh` access to both.
Amala avatar
ma flag
@Jos - Yes we do have the SSH permissions as well.
uz flag
Jos
Try `rsync` as explained here: https://unix.stackexchange.com/questions/183504/how-to-rsync-files-between-two-remotes/183516
cn flag
I would anytime choose ssh over sftp. The command you should be looking at is ```scp```
Amala avatar
ma flag
@Jos - rsync is not available in our Linux servers. I am trying to connect to source server, Find the files modified or created between 2 dates, And then copy into Target server with the same directory structure.
Score:0
cn flag

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>

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.