You will of course need to run ssh-copy-id root@hostname
for each machine you want to connect to prior to running this script.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
#!/bin/bash # declare an array called array and define 3 vales osdirs=( "/etc/nova" "/etc/neutron" "/etc/cinder" "/etc/glance" "/etc/keystone" "/etc/httpd" ) servers=("vm-os-ks01" "vm-os-glance01" "vm-os-dash01" "vm-os-net01" "vm-os-net02" "vm-os-cinder01" "vm-os-radosgw01" ) for s in "${servers[@]}" do for d in "${osdirs[@]}" do echo "Server $s Dir $d" scp -r root@$s:$d /root/backups/$s/$d done done |