/tool e-mail
set address=smtp.gmail.com from="Router #2" password=Redacted port=587 \
start-tls=yes user=address@gmail.com
# Policies needed: ftp, read, policy, sensitive, test
# Policies NOT needed: password, reboot, write, sniff, romon
:log info "Starting daily backup";
/system backup save name=RB750-2_Daily
/system package print file RB750-2_Version.txt
:delay 00:00:01
/tool e-mail send file=RB750-2_Daily.backup to="jim@Redacted.com" body="Router #2 daily backup file attached." \
subject="RB750r2-2 $[/system clock get date] at $[/system clock get time] Backup"
/ export file RB750-2_Daily
:delay 00:00:10
/tool e-mail send file=RB750-2_Daily.rsc,RB750-2_Version.txt to="jim@Redacted.com" body="Router #2 daily script and version files attached." \
subject="RB750r2-2 $[/system clock get date] at $[/system clock get time] Script"
:log info "Daily backup script completed"
/system scheduler
add interval=1d name="Daily backup" on-event="Daily Backup" policy=\
ftp,read,write,policy,test,password,sniff,sensitive start-date=\
jul/12/2016 start-time=22:32:00
But my question is it possible to save backup file only if settings were changed, for example if last record (but record #0) in "/system history" has later date/time than date/time of existed backup file?/file remove [find name="email_bak.backup"];
/system backup save name=email_bak;
:delay 5;
/tool e-mail send file="email_bak.backup" to="xxxxx@gmail.com" from=yyyyy@gmail.com body="See attached file" subject="Mikrotik Backup $[/system identity get name] $[/system clock get date] $[/system clock get time]";
Yeap, you're right. /system history is active only during the user's session. On regular basis only /log is used and there we don't have opportunity to track the changes.The change-only determination is probably too difficult to be worth the effort. You can't compare files in RouterOS (string variables have definite maximum lengths) and there is no easy indicator for "date configuration last modified."
That's correct, you are right again. import file after first connect, reboot and that's all.One comment I will make is that I would recommend you use export, and mail the results of that, instead of mailing backup files. Backup files are comparatively huge, many email servers will not accept them, and they are only good for the physical board they were made from; whereas rsc files are smaller, can be used to "clone" to a new board if the old one gets hit by lightning, and can be compared with a simple diff application.
We have all our units email fresh rsc exports to an archival account twice per week, we save the first copy as a baseline, and whenever we need to do a comparison, after we approve the current configuration as acceptable, we copy that to the baseline instead.