#!/bin/bash line="$(grep 'backup' /etc/rsnapshot.conf | grep 'public_html')" match=$(echo "$line" | awk '{print $2}' | cut -d / -f4) size_after_backup="$(du -cah /data/backup/*.0 -b | grep "$match" | tail -1 | cut -f1)" size_before_backup="$(du -cah /data/public_html/$match -b | grep "$match" | tail -1 | cut -f1)" echo "$match" echo "$size_after_backup" echo "$size_before_backup" if [ $size_after_backup -lt $((size_before_backup - 200)) ] || [ $size_after_backup -gt $((size_before_backup + 200)) ] || [ $size_after_backup -eq $size_before_backup ] && [ $size_after_backup -ne 0 ] && [ $size_before_backup -ne 0 ]; then echo "backup at $HOSTNAME is succeeded." > /tmp/backup_result else echo "backup at $HOSTNAME is failed." > /tmp/backup_result fi