LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-05-2013, 11:34 PM   #1
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora
Posts: 2,630

Rep: Reputation: 495Reputation: 495Reputation: 495Reputation: 495Reputation: 495
rsync question


is it possible to use rsync to copy files from one directory into multiple directories at once without having to chain rsync together?

ex:

Code:
rsync -aviS /source /backup1 /backup2 /backup3 ...
Thanks.
 
Old 01-06-2013, 06:26 AM   #2
Snark1994
Senior Member
 
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
I don't believe it is... The think best you'll get is

Code:
for dest in /backup1 /backup2 /backup3; do
    rsync -aviS /source $dest
done
Regards,
 
Old 01-06-2013, 08:01 PM   #3
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora
Posts: 2,630

Original Poster
Rep: Reputation: 495Reputation: 495Reputation: 495Reputation: 495Reputation: 495
ok thanks. that is what i thought, but i was hoping there was a way to send the files to multiple destinations at once. oh well.
 
Old 01-06-2013, 08:41 PM   #4
soupmagnet
LQ Newbie
 
Registered: Sep 2012
Posts: 27

Rep: Reputation: Disabled
Quote:
Originally Posted by lleb View Post
ok thanks. that is what i thought, but i was hoping there was a way to send the files to multiple destinations at once. oh well.
Just pipe your commands together:
Code:
rsync -aviS /source /destination1 | rsync -aviS /source /destination2 | rsync -aviS /source /destination3
Or pipe functions together in a shell script:

Code:
dest1(){
rsync -aviS /source /destination1
}

dest2(){
rsync -aviS /source /destination2
}

dest3(){
rsync -aviS /source /destination3
}

dest1 | dest2 | dest3
 
Old 01-07-2013, 04:56 AM   #5
Snark1994
Senior Member
 
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
@soupmagnet: I'm not sure that does what you think it does... You use piping to pass output from one command to another. If you just want to run them in sequence, regardless of the return status of the previous command, separate them with semicolons, or just put them on separate lines.
 
Old 01-07-2013, 05:04 AM   #6
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,349

Rep: Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748
by default, based on rsync internals rsync can only handle one destination (because it is compared to the sources)
 
1 members found this post helpful.
Old 01-07-2013, 06:39 AM   #7
alieblice
Member
 
Registered: Jul 2011
Posts: 80

Rep: Reputation: Disabled
if it going to send source file it should sync source to all destination separately. so it will be same as running it more than 1 time for different destination.
if you always use 1 repetitive command for all those destination it might be good idea to make alias of those command.
 
Old 01-07-2013, 04:06 PM   #8
soupmagnet
LQ Newbie
 
Registered: Sep 2012
Posts: 27

Rep: Reputation: Disabled
Quote:
Originally Posted by Snark1994 View Post
@soupmagnet: I'm not sure that does what you think it does... You use piping to pass output from one command to another. If you just want to run them in sequence, regardless of the return status of the previous command, separate them with semicolons, or just put them on separate lines.
I understand piping, at least at the surface. But I have been able to (seemingly) run commands simultaneously with it (i.e. using wget to download seperate files). If I pipe two wget functions together to download large files and have each function check for the other file before continuing, or have a loop to check that all files are downloaded before continuing, the files will download simulatneously (again, seemingly), rather than waiting for one to download before starting on the next.

In this case, it tested out to be functional. I used three destinations for a fairly large source directory and the resulting directories, using 'diff', match the source directory and the other destination directories. Obvoiusly, I'm still learning, so what exactly is wrong with piping commands together for the purpose of simply running them simultaneously?

And thank you for your input.

Last edited by soupmagnet; 01-07-2013 at 04:11 PM.
 
Old 01-07-2013, 07:05 PM   #9
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,362

Rep: Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377
As per post #5; piping is for sending the output of the first cmd to the input of the 2nd cmd and so on.
In this case its redundant (even though it would still 'work'), because there is no dependency between the cmds/fns.
If you wanted them to run concurrently you could background them all
Code:
dest1 &
dest2 &
dest3 &
If there's no output/input dependency, but you want to only run subsequent cmds if prev ones succeed, use '&&'
Code:
dest1 && dest2

These are worth bookmarking/reading
http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/

Last edited by chrism01; 01-07-2013 at 07:06 PM.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
rsync question mokku Linux - Newbie 1 05-31-2008 08:56 AM
rsync question mahmoud Linux - Software 5 04-25-2008 05:13 AM
rsync question hepburnenthorpe Linux - General 1 11-19-2006 05:19 PM
rsync question nazs Linux - Software 1 10-23-2006 07:31 PM
Rsync Question stefaandk Linux - General 2 05-12-2006 11:12 PM


All times are GMT -5. The time now is 10:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration