Skip to content

Instantly share code, notes, and snippets.

@gmanual
Last active May 1, 2019 23:40
Show Gist options
  • Save gmanual/79173d5733a27e7ccc67c130627b0c7b to your computer and use it in GitHub Desktop.
Save gmanual/79173d5733a27e7ccc67c130627b0c7b to your computer and use it in GitHub Desktop.
global routername test-router
global sendtoemail routerbackups@domain.com
global sendfromdomain domain.com
global smtphost host.domain.com
global smtpuser username@domain.com
global smtppass password
global smtpport 587
global smtpstarttls yes
/system identity set name=("$routername-" . [/system routerboard get serial-number])
/system script
add comment=("Added - " . [/system clock get date] . " - Router Backup Script") name=backup-script owner=admin policy=ftp,read,write,test source="/export compact file=[/system identity get name]\r\
\n\r\
\n:delay 5s\r\
\n\r\
\n/tool e-mail send file=([/system identity get name] . \".rsc\") to=\"$sendtoemail\" body=\"See attached file for System Backup\" subject=([/system identity get name] . \" \" . [/system clock get time] . \" \" . [/system clock g\
et date]. \" Backup\")\r\
\n\r\
\n:log info (\"System Backup emailed at \" . [/sys cl get time] . \" \" . [/sys cl get date])\r\
\n\r\
\n:delay 5s\r\
\n\r\
\nfile remove [/system identity get name]"
/system scheduler
add comment=("Added - " . [/system clock get date] . " - Router Backup Script") interval=1w name=backup-schedule on-event=backup-script policy=read start-time=00:00:00
/tool e-mail
set address=$smtphost from=([/system identity get name] . "@$sendfromdomain") password=$smtppass port=$smtpport user=$smtpuser start-tls=$smtpstarttls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment