RE: Master rsync script for many file servers
"Geoffrey Scott" <[email protected]> Thu, 11 May 2006 10:29:44 +1000
| Newsgroups | gmane.org.user-groups.mlug.main |
|---|---|
| Message-ID | <9DE681DC93551E4FA4C5B50D8BD90F3017D645@gfh-mail-01.guestsfurniturehire.com.au> |
Geoffrey Scott wrote: > Hi people, > I am trying to write a grand unified rsync script that will backup a > number of servers spread throughout the country to one central > server. I decided to call the rsync script from another script as per my text below. But I am having some problems with ssh'ing to another server and shutting down services prior to the rsync process. Can someone help me figure out why locally a command will run but not on another server? Please see the bottom text..... > > I know I could make another script that called the rsync backup > script with the server name as an argument and then "case" in the > rsync script would be easy to use, like this: > ============================================================== > SERV2B="serv1 serv2 serv3" > > for b in $SERV2B > do > ./rsync-script.bash $b > done > ============================================================== > But I was hoping someone could teach me a more pro way........ > So I define the services I want to shut down: SERVICES="smb cups postfix" And this works locally: for s in $SERVICES; do if [ -e /etc/init.d/$s ]; then /etc/init.d/$s start; fi; done But not on another server.... : for s in $SERVICES; do ssh [email protected] if [ -e /etc/init.d/$s ]; then /etc/init.d/$s start; fi; done Because it says this: -bash: syntax error near unexpected token `then' Any ideas why this doesn't work????? Regards Geoff Scott