数据库备份脚本(整库备份)
转载请注明出处:https://www.cnblogs.com/stromgao/p/12030357.html
windows版(.bat):
windows如何启动定时任务,自行找度娘。
set "Ymd=%date:~,4%%date:~5,2%%date:~8,2%"
D:\mariadb-10.3.20\bin\mysqldump --opt -u root --password=123456 --all-databases > E:\mysqlBak\data_bak\dataBak_%Ymd%.sql
linux版(.sh):
#!/bin/bash DATE=`date +%Y%m%d_%H%M%S` BACKUPDIR='/home/yopdata_bak' #mysqldump -h10.252.135.206 -P3306 -uroot -p123456 --all-databases > $BACKUPDIR/mysqldata_$DATE.sql mysqldump -h10.252.135.206 -P3306 -uroot -p123456 --all-databases > $BACKUPDIR/mysqldata_$DATE.sql find $BACKUPDIR -name "mysqldata_*.sql" -type f -mtime +1 -exec rm {} \; > /dev/null 2>&1
随笔看心情