#!/bin/bash # export and backup the abgent_web database.sql mysqldump -uuser -ppassword ltden_db --skip-lock-tables > /home/ltden/auto_backup/database.sql #zip the code and database.sql cd /home/ltden/auto_backup/ tar -zcvf /home/ltden/auto_backup/ltden_db$(date +%Y%m%d%H%M).tar.gz database.sql #delete the abgent_web database.sql rm -f /home/ltden/auto_backup/database.sql #delete backup zip 90 days ago DAYS=90 find /home/ltden/auto_backup/ -name "ltden_db*" -type f -mtime +$DAYS -exec rm {} ;