#!/bin/bash
DATE=$(date +%F_%H%M)
HOST=
USER=
PASS=
BACKUP_DIR=/data/db_backup
BACKUP_NAME=$BACKUP_DIR/edoc2v5_${DATE}.sql

mysqldump -h$HOST -u$USER -p$PASS --force -A > $BACKUP_NAME

if [ $? -ne 0 ];then
    echo "[$DATE] $BACKUP_NAME 备份失败!" >> /tmp/edoc2v5_bak.log
else
    find $BACKUP_DIR -name "*.sql"  -mtime +7  -exec rm -f {} \;
fi
