shell 备份脚本

时间:2021-08-07 22:55:14
[root@izwz9hmoz58gvtu0ldpm0iz ~]# cat /usr/local/aaaa/shell_script/Mysql_Dump_LJY.sh
#! /bin/bash today=`date +%Y%m%d%H`
yesterday=`date -d "1 day ago" +%Y%m%d`
work_dir="/usr/local/haha/database_bakcup" #############dump###############
cd ${work_dir}
mkdir ${today}_DB_Dump_LJY
/usr/bin/mysqldump -uaaaa -p1234 -h192.168.1.1 Online > aaaonline_${today}.sql
/usr/bin/mysqldump -uaaaa -p1234 -h192.168.1.1 account_2 > aaaa_account_${today}.sql mv *.sql ${today}_DB_Dump_aaaa/.
tar czvf ${today}_DB_Dump_aaaa.tar.gz ${today}_DB_Dump_aaa
rm -rf ${today}_DB_Dump_aaa
#############del################
find $work_dir/*.tar.gz -mtime +5 | xargs rm -rf