首页 > 其他分享 >每天备份目录到远程

每天备份目录到远程

时间:2023-02-01 14:47:20浏览次数:38  
标签:count remotebak 备份 目录 record path echo 远程 today

 

#Backup records to other folder everyday.
#定义备份的源目录、目标目录,备份每天日期的文件夹 today=`date -d "now" +%Y%m%d` record_path="/var/spool/records" record_remotebak_path="/Record_bak/" record_path_today="$record_path/$today" record_remotebak_path_today="$record_remotebak_path/$today" echo $record_path_today #检查源目录是否存在 if [[ -d "$record_path_today" ]]; then cp -r $record_path_today $record_remotebak_path else echo "$record_path_today not exist" fi #检查源文件数量和白粉文件数量是否相同 record_count_today=`ls $record_path_today/ |wc -l` record_count_today_bak=`ls $record_remotebak_path_today/ |wc -l` #echo $record_count_today #echo $record_count_today_bak if [ $record_count_today -ne $record_count_today_bak ]; then ntime=`date -d "now" "+%Y-%m-%d %H:%M:%S"` echo "$ntime,num error, source files number is $record_count_today, bakup files number is $record_count_today_bak." fi

 

标签:count,remotebak,备份,目录,record,path,echo,远程,today
From: https://www.cnblogs.com/dreamer-fish/p/17082500.html

相关文章