Backup

Вариант 1

Поменять <SERVER>, <USER> и <PASSWORD>на свои значения FTP сервера

/log info "backup starting";
:local CurrentTime [/system clock get time];
:local CurrentDate [/system clock get date];
:local Hour [:tostr [:pick $CurrentTime 0 2]];
:local Min [:tostr [:pick $CurrentTime 3 5]];
:local Day [:tostr [:pick $CurrentDate 4 6]];
:local Month [:tostr [:pick $CurrentDate 0 3]];
:local Year [:tostr [:pick $CurrentDate 7 [:len $CurrentDate]]];
:global name=backupfile value=([/system identity get name] ."__$Day_$Month_$Year__$Hour_$Min.backup")
:global name=scriptfile value=([/system identity get name] ."__$Day_$Month_$Year__$Hour_$Min.rsc")
/system backup save name=$backupfile;
/export verbose file=$scriptfile;
:delay 10s
/tool fetch address=<SERVER> src-path=$backupfile user=<USER> mode=ftp password=<PASSWORD> dst-path="backup/$backupfile" upload=yes;
/tool fetch address=<SERVER> src-path=$scriptfile user=<USER> mode=ftp password=<PASSWORD> dst-path="backup/$scriptfile" upload=yes;
:delay 20s
/file remove $backupfile;
/file remove $scriptfile;
/log info "backup finished";

Вариант 2

Поменять <SERVER>, <USER> и <PASSWORD>на свои значения FTP сервера

/system scheduler
add disabled=no interval=5d name=backup on-event=backup policy=\
  ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \
  start-date=jan/10/2020 start-time=00:00:01
/system script
add dont-require-permissions=no name=backup owner=su policy=\
  ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="/\
  log info \"backup starting\";\r\
  \n:local CurrentTime [/system clock get time];\r\
  \n:local CurrentDate [/system clock get date];\r\
  \n:local Hour [:tostr [:pick \$CurrentTime 0 2]];\r\
  \n:local Min [:tostr [:pick \$CurrentTime 3 5]];\r\
  \n:local Day [:tostr [:pick \$CurrentDate 4 6]];\r\
  \n:local Month [:tostr [:pick \$CurrentDate 0 3]];\r\
  \n:local Year [:tostr [:pick \$CurrentDate 7 [:len \$CurrentDate]]];\r\
  \n:global name=backupfile value=([/system identity get name] .\"__\$Day_\$\
  Month_\$Year__\$Hour_\$Min.backup\")\r\
  \n:global name=scriptfile value=([/system identity get name] .\"__\$Day_\$\
  Month_\$Year__\$Hour_\$Min.rsc\")\r\
  \n/system backup save name=\$backupfile;\r\
  \n/export verbose file=\$scriptfile;\r\
  \n:delay 10s\r\
  \n/tool fetch address=<SERVER> src-path=\$backupfile user=<USER>\
  r mode=ftp password=<PASSWORD> dst-path=\"backup/\$backupfil\
  e\" upload=yes;\r\
  \n/tool fetch address=<SERVER> src-path=\$scriptfile user=<USER>\
  r mode=ftp password=<PASSWORD> dst-path=\"backup/\$scriptfil\
  e\" upload=yes;\r\
  \n:delay 20s\r\
  \n/file remove \$backupfile;\r\
  \n/file remove \$scriptfile;\r\
  \n/log info \"backup finished\";\r\
  \n"