自动备份数据库crond

#!/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 {} \; 

  

posted @ 2018-06-22 15:24  WWSASUKE  阅读(97)  评论(0编辑  收藏  举报