I've just made this script, full.rsc, wich does 3 things in the router.
1. Configures email tool so the next script is able to use it.
2. Creates a script that sends a) a full backup to an email address and b) an "rsc" backup to an email address
3. Creates a job in scheduler so the script runs everyday at 23.30.
4. Deletes itself.
I'm not a programmer, but it was easy to do it as I did. But I want to make it more friendly.
I want my techs to install this in every router they configure, so I want it to ask to the tech (when he writes "import full.rsc" in terminal) wich subject to use when sending the emails.
Could you help me? Feel free to use this code and edit for whatever you want :)
Here's full.rsc source (sensible information is replaced by blablabla, but is used as it should in real rsc):
Code: Select all
/tool e-mail
set address=smtp.ionos.es from="" password=blablabla port=587 start-tls=\
yes user=blablabla
/system script
add dont-require-permissions=no name=BackupEmail owner=blablabla policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source=":\
log warning \"Comenzando envio de backups automatico\"\r\
\n:log info \"Preparando y enviando backup COMPLETO\"\r\
\n/system backup save name=config\r\
\n:delay 25s\r\
\n/tool e-mail send file=config.backup to=\"blablabla\" from=rb-10.1\
00.10.1@blablabla body=\"Backup en formato BACKUP adjunto\"\
\_subject=\"Backup RB 10.100.10.1\"\r\
\n:delay 10s\r\
\n:log info \"Preparando y enviando backup RSC\"\r\
\n/export file=configRSC.rsc\r\
\n:delay 25s\r\
\n/tool e-mail send file=configRSC to=\"blablabla\" from=rb-10.100.1\
0.1@blablabla body=\"Backup en formato RSC adjunto\" subjec\
t=\"Backup RSC RB 10.100.10.1\"\r\
\n:delay 10s\r\
\n:log warning \"Script de backups automaticos finalizado\""
/system scheduler
add interval=1d name=Backups on-event=BackupEmail policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \
start-date=may/04/2021 start-time=23:30:00
/file remove full.rsc
Have a nice day!