From Kromonos, 3 Years ago, written in Bash.
Embed
  1. #!/bin/bash
  2. # https://www.youtube.com/watch?v=RTsEt18Q1S0
  3.  
  4. SRV1="example.de"
  5. SRV2="exsample.com"
  6. SRVUP1=$(ping -c 1 $SRV1 > /dev/null; echo $?)
  7. SRVUP2=$(ping -c 1 $SRV2 > /dev/null; echo $?)
  8.  
  9. RSYNC="rsync -PHAXphax --delete"
  10. BORGDIR="/home/backup/borg"
  11.  
  12. # rsync backups from servers
  13. #
  14. if [ $SRVUP1 -eq 0 ]
  15. then
  16.     $RSYNC --rsync-path="sudo rsync" server:borg/$SRV1 $BORGDIR
  17.  
  18.     echo "Backup from $SRV1 successfully." | /usr/bin/systemd-cat -t "borg"
  19. else
  20.     echo "$SRV1 is down!" | /usr/bin/systemd-cat -t "borg"
  21. fi
  22.  
  23. if [ $SRVUP2 -eq 0 ]
  24. then
  25.     $RSYNC --rsync-path="sudo rsync" ns2:borg/$SRV2 $BORGDIR
  26.  
  27.     echo "Backup from $SRV2 successfully." | /usr/bin/systemd-cat -t "borg"
  28. else
  29.     echo "$SRV2 is down!" | /usr/bin/systemd-cat -t "borg"
  30. fi
  31.  
  32.  
  33. # rsync offsite-backup to SRV1
  34. #
  35. if [ $SRVUP1 -eq 0 ]
  36. then
  37.     $RSYNC --rsync-path="sudo rsync" --exclude 'server.derhil.de*' $BORGDIR/ server:borg
  38.  
  39.     echo "Offsite-backup to $SRV1 successfully." | /usr/bin/systemd-cat -t "borg"
  40. else
  41.     echo "$SRV1 is down!" | /usr/bin/systemd-cat -t "borg"
  42. fi