F
F
fdroid2017-06-24 22:02:06
bash
fdroid, 2017-06-24 22:02:06

How to write a script for rsync?

There is a task to rsync one webdav directory to another - from serv1 to serv2. I must say right away that I am familiar with programming only at the level of Spectrum Basic, but I think I can master simple scripts. Approximately, I imagine the implementation as follows:
10 Running the script
20 Mounting the webdav directory of server 1 to /mnt/serv1 #this is a local webdav directory, so it is definitely available
30 Ping serv2 #this is a remote server
40 If serv2 responds to ping, then mount the webdav directory of server 2 to /mnt/serv2 otherwise GO TO 100
50 rsync /mnt/serv1 /mnt/serv2
60 Unmount /mnt/serv2
70 Unmount /mnt/serv1
80 e-mail to admin that the task is done
90 Exit script
100 e-mail to the admin that serv2 is unavailable, the task is not completed
How to organize lines 30 and 40 - i.e., how to set the execution conditions for the availability of serv2, and also make the transition GO TO 100 if it does not ping? It is clear that there will be no numbered lines in the scripts, it was just like that in BASIC.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2017-06-24
@fdroid

if ping -c2 yandex.ru  > /dev/null; then
  echo "есть контакт, яндекс доступен "
else
mail -s "hello" "[email protected]" <<EOF
А сервер то недоступен, сообщение многострочное. йеоэф это конец и начало сообщения 
EOF
fi

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question