automatic backup dude database on external ftp server.
/system scheduler
add interval=1d name=backup on-event=backup policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive start-date=\
nov/04/2015 start-time=03:00:00
/system script
add name=backup policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive source="# Set l\
ocal variables. Change the value in \"\" to reflect your environment.\r\
\n\r\
\n:local hostname \"dude\";\r\
\n:local password \"pass-ftp\"\r\
\n:local username \"user-ftp\"\r\
\n:local ftpserver \"10.36.8.12\"\r\
\n\r\
\n# Set Filename variables. Do not change this unless you want to edit the\
\_format of the filename.\r\
\n\r\
\n:local date ([:pick [/system clock get date] 0 3] \\\r\
\n. [:pick [/system clock get date] 4 6] \\\r\
\n. [:pick [/system clock get date] 7 11]);\r\
\n:local filename \"\$hostname-\$date\";\r\
\n\r\
\n# Create backup file and export the config.\r\
\n\r\
\nexport compact file=\"\$filename\"\r\
\ndude export-db \"\$filename.bkp\"\r\
\n\r\
\n:log info \"Backup Created Successfully\"\r\
\n\r\
\n# Upload config file to FTP server.\r\
\n\r\
\n/tool fetch address=\$ftpserver src-path=\"\$filename.rsc\" \\\r\
\nuser=\$username mode=ftp password=\$password \\\r\
\ndst-path=\"/rsc/\$filename.rsc\" upload=yes\r\
\n\r\
\n# Upload backup file to FTP server.\r\
\n\r\
\n/tool fetch address=\$ftpserver src-path=\"\$filename.bkp\" \\\r\
\nuser=\$username mode=ftp password=\$password \\\r\
\ndst-path=\"/dude/\$filename.bkp\" upload=yes\r\
\n\r\
\n:log info \"Backup Uploaded Successfully\"\r\
\n\r\
\n# Delete created backup files once they have been uploaded\r\
\n# so they don't accumulate and fill up storage space on the router.\r\
\n\r\
\n/file remove \"\$filename.rsc\"\r\
\n/file remove \"\$filename.bkp\"\r\
\n\r\
\n:log info \"Local Backup Files Deleted Successfully\""