Check disk usage before backup to usb

This commit is contained in:
Bob Mottram 2015-11-06 15:59:16 +00:00
parent cd2715de04
commit 53740e6ebf
1 changed files with 17 additions and 0 deletions

View File

@ -2585,7 +2585,24 @@ function create_backup_script {
echo ' rm -rf $USB_MOUNT' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' exit 27' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo -n 'used_percent=$(df -k $USB_MOUNT | ' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo -n "awk -F ' ' '{print " >> /usr/bin/$BACKUP_SCRIPT_NAME
echo -n '$5' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo -n "}' | " >> /usr/bin/$BACKUP_SCRIPT_NAME
echo -n "awk -F '%' '{print " >> /usr/bin/$BACKUP_SCRIPT_NAME
echo -n '$1' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "}')" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'if [ $used_percent -gt 95 ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' ' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "Less than 5% of space remaining on backup drive"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' umount $USB_MOUNT' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' rm -rf $USB_MOUNT' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' exit 6492' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '# MariaDB password' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo -n 'DATABASE_PASSWORD=$(cat ' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "$DATABASE_PASSWORD_FILE)" >> /usr/bin/$BACKUP_SCRIPT_NAME