ros3.3定时备份系统脚本
复制脚本粘贴到system scheduler里面设置成每天执行,比如今天是2012年12月11日,此脚本自动会备份一个文件名为:12112012的backup文件,以后每天都有个以日期为标准的文件备份,脚本到次月时间的1号会自动删除上月所有的备份文件,重新开始备份.
下面是系统备份脚本:
下面是系统备份脚本:
:do { :local date [/system clock get date] :local day [:pick $date 4 6] :local month [:pick $date 0 3] :local year [:pick $date 7 11] :local convert ([:find jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec [:pick $date 0 3]]+1); :if ($convert <=9) do={ :set convert ("0".$convert)} :set date ($convert.$day.$year); /system backup save name=$date; :delay 3s; :foreach j in=[/file find] do={ :local name1 [/file get $j name]; :if ([:len $name1]="15") do={ :local name2 [/file get $j name]; :local month1 [:pick $date 0 2]; :local day1 [:pick $date 2 4]; :local year1 [:pick $date 4 8]; :local month2 [:pick $name2 0 2]; :local day1 [:pick $name2 2 4]; :local year2 [:pick $name2 4 8]; :if ($year1=$year2 && month2 < $month1) do={ /file remove $name2;}; :if ($year1 > $year2) do={ /file remove $name2;};}}}
评论: