Using rsync in a Script
I want to use rsync in a shell script. To get rsync
to read 2 files the syntax requires a space separated list enclosed in
single quotes e.g.
rsync -e ssh -avz root@server:'/etc/file1 /etc/file2'
destination
However, I want to put in a shell script the following
(basically)...
FILES='/etc/file1 /etc/file2'
rsync -e ssh -avz root@server:$FILES destination
It falls over :-(
I've tried..
FILES='/etc/file1 /etc/file2'
FILES="'/etc/file1 /etc/file2'"
and
FILES=''/etc/file1 /etc/file2''
and some variations but it won't work and I'm getting
dizzy !
Obviously the '/etc/file1 /etc/file2' needs to be
enclosed in something but I can't figure it. Tried Googling without success
and can't find an example anywhere.
Hope someone can point me in the right direction -
I'm a newbie to shell scripts & linux.
FILES='/etc/file1 /etc/file2'
for file in $FILES ; do
rsync -e ssh -avz root@server:$file destination
done
Have a Linux Problem
Linux Forum
- Do you have a Linux Question?
Linux Books
Linux Certification,
System Administration, Programming, Networking Books
Linux Home: Linux
System Administration Hints and Tips
(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.
Information used on this site is at your own risk.
All product names are trademarks of their respective
companies.
The site www.gotothings.com is in no way affiliated with
or endorsed by any company listed at this site.
Any unauthorised copying or mirroring is prohibited.
|