• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 735
  • Last Modified:

Is it possible to copy multiple files from multiple directories at once from server A to server B?

How can i copy multiple different files from different directories from one server to another server? Is there a script that could be written for it?
Can i list the location of files in a touch file and use that within a command syntax to copy it all at once?
0
assistunix
Asked:
assistunix
  • 3
  • 3
  • 2
  • +4
3 Solutions
 
aadi369Commented:
It will be a long procedure......copy one by one.....its the easiest, safer and the simple way.
0
 
ahoffmannCommented:
is the destination the same directory for all files?
0
 
jlevieCommented:
Is the goal to update a directory(s) on one machine with data from another machine? If so rsync would be the best solution. We need a bit more information to suggest the best solution.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
fridomCommented:
rsync with a file-list would be my preferred way of doing it.
0
 
Duncan RoeSoftware DeveloperCommented:
@assistunix: please tell us in more detail what exactly it is that you want to do.
There are a number of suggestions above, and I have another one: do you want to copy a number of files from various places in one system to the same places on another?
The reason I ask is that I developed a script like that at work. It uses a text file to generate ftp commands to do the job
0
 
skullnobrainsCommented:
scp /path/to/file/1 /different/path/to/file/2 destination_host:/destination/path

should also work using rcp, sftp, ftp ..

---

if you need to do multiple copies of multiple files to different location, some of these commands can be driven interactively (so consider expect) or use batch files.

much simpler, use tar over telnet, rlogin, or ssh

tar cvf - /path/to/file /other/path ... | ssh ... | tar xvf -

it should be pretty easy to script any of this

obviously consider rsync as well
0
 
assistunixAuthor Commented:
Yes- the source server and the target server both have same dir location.
there are 30 files in /home on serverA which i want to copy to /home on serverB.

Instead of doing it one by one- I would like to be able to do it all at once.
How can i do that?
0
 
fridomCommented:
scp "server1:/home/*" server2:/home

maybe with some extra switshes will do.
0
 
skullnobrainsCommented:

Yes- the source server and the target server both have same dir location.

read our posts and/or the scp man page : this is irrelevant.
what is relevant is wether you copy all the files TO the same location or not
(see first line of my post)
actually you could even copy files from different servers


there are 30 files in /home on serverA which i want to copy to /home on serverB.

 this is inconsistent with your original question


multiple different files from different directories

given this new information, use either of these commands

scp server1:/home/* server2:/home/

or

scp -r server1:/home/ server2:/
0
 
assistunixAuthor Commented:
scp server1:/home/* server2:/home/  won't help me.

My last post was an example to make the question simpler, clearly it didn't.

Let me clarify it further.
Scenario:
I have 100+ files in /home on serverA.
What i want to do is, copy 30 of those 100 files all at once from /home serverA to /home ServerB.
0
 
fridomCommented:
Well then you have to qualify which files you want to copy you always can write:
scp server1:/home/{file_a, file_b, file_c...}
and you can achieve that with an include/exclude file.

What you must do of course is "filtering" for the files you like to transfer.
0
 
skullnobrainsCommented:
scp 'server1:/home/{file_a, file_b, file_c...}'
quotes added or you would have to escape the curly brackets

scp server1:/home/file_a server1:/home/file_b server1:/home/file_c ... destination_server:/home/
may be easier to type

if you wanted something to automatically copy all the files but 30 by 30, you can code a simple one-liner

find /home/ -type f -print | sed 's/.*/server1:&/' | xargs -n 30 scp

i tryed to be compatible with most unix-like systems, but you may need to adjust
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
  • 2
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now