NOC:ctwug backup

From CTWUG Wiki
Jump to: navigation, search

Purpose

  • Finds and deletes any existing backups
  • Creates a backup
  • Emails the backup file to the ctwug backup server email address

Dependencies

  • email address: backup@ctwug.za.net
  • email server : 172.18.55.25

Script

:local fid [/system identity get name]
:local fserial [/system routerboard get serial-number] 

:if ( [/file find name=ctwug-auto.backup] != "" ) do=[/file remove ctwug-auto.backup]
:delay 1
/system backup save name=ctwug-auto
:local fwait 1
:local fcnt 0
:while ( $fwait = 1 ) do={
  :set fcnt ($fcnt+1)
  :log info ("ctwug_backup sleep ".$fcnt)
  :delay 1
  if ([/file find name=ctwug-auto.backup] != "") do={ :set fwait 0; }
  if ( $fcnt = 20) do={
    :log info "ctwug_backup FAILED";
    :set fwait 0;
  };
};
:local femail backup@ctwug.za.net
:local fserver 172.18.55.25
/tool e-mail send server=$fserver from=$femail to=$femail subject="$fid/$fserial" file=ctwug-auto.backup