I have a script which will be running in each server and copies certain files into it. Script knows where I am running and what files I need to copy.Script will copy files from local datacenter local_dc but if it is down or not responding, then it will copy same files from remote datacenter remote_dc_1 and if that is also down, then it will copy same files from another remote datacenter remote_dc_2 as shown below -do_Copy() {  el=$1  PRIMSEC=$2  scp david@$local_dc:$dir3/new_weekly_2014_$el_200003_5.data $PRIMSEC/. || scp david@$remote_dc_1:$dir3/new_weekly_2014_$el_200003_5.data $PRIMSEC/. || scp david@$remote_dc_2:$dir3/new_weekly_2014_$el_200003_5.data $PRIMSEC/.}export -f do_Copy# copying 5 files in parallel simultaneously in primary and secondary folderparallel --retries 10 -j 5 do_Copy {} $PRIMARY ::: $primary_partition &parallel --retries 10 -j 5 do_Copy {} $SECONDARY ::: $secondary_partition &waitecho All files copied successfully.Now my question is :Let's say if local_dc machine is down, then will it definitely copy from remote_dc_1 machine for sure? And if remote_dc_1 machine is also down, then will it also copy from remote_dc_2?Now if all three machines are down then what will happen? In this case, I want to print the message saying, all three machines are down so exiting out of the shell script.I cannot test this properly without making the machine down.
How to copy files from other servers if local machine is down
linux;bash;scp;gnu parallel
Yes. It will attempt to copy from the first, if that fails it will try the second and if that fails too, it will try the third. To have it email you at the end, use this:scp ... || scp ... || scp || echo All attempts failed | mailx -r foo@bar.comTo have each scp command tell you if it failed, you can use subshells:scp ... || (echo machine1 down | mailx -r foo@bar.com&& scp ... ) ||( echo machine2 down | mailx -r foo@bar.com && scp ... ) ||      echo All attempts failed | mailx -r foo@bar.com