备份脚本
1/ #备份cm(node1)的mysql到tableau-2
00 06 * * * /bin/sh /hongfeng/script/node1_mysql_backup.sh >/dev/null 2>&1
#! /bin/sh
date=$(date +%Y-%m-%d)
mysqldump --all-databases --single_transaction --master-data=2 -uroot -P3306 > /data/backup/cdh_db${date}.sql
filename=`find /data/backup/ -name "*$date*"`
if [ -f "$filename" ]
then
scp $filename 10.52.135.178:/data/node1_mysql_backup/
rm -f $filename
fi
在tableau2上删除:
vim /hongfeng/script/del_node1_db.sh
find /data/node1_mysql_backup -mtime +7 -name "cdh_db*.db" -exec rm -Rf {} \;
00 01 * * * /bin/sh /hongfeng/script/del_node1_db.sh >/dev/null 2>&1
删除目录同样:
find /home/airflow/airflow/logs/scheduler/ -mtime +7 -name "2020-*" -exec rm -Rf {} \;
或者:
find /home/airflow/airflow/logs/scheduler/ -mtime +6 -name "2020-*" -type d|xargs rm -Rf