小小的东东,用于数据库的备份。
留存。
#!/bin/sh keepDays=30 currentTime=`date "+%Y-%m-%d-%H-%M"` backPath="/sql_bak/" dbName="smDB" echo ${currentTime} /usr/bin/mysqldump --default-character-set utf8 -u xxx --password=xxx --database ${dbName} > ${backPath}${dbName}.${currentTime}.sql; /usr/bin/scp ${backPath}${dbName}.${currentTime}.sql dxx@1.2.3.4:${backPath}${dbName}.${currentTime}.sql; find ${backPath} -name "*.sql" -mtime +${keepDays} -exec rm {} \; ssh -l xxx 1.2.2.2 "find ${backPath} -name '*.sql' -mtime +${keepDays} | xargs rm -f "