Jump to content

Неработещ скрипт


prompt
 Share

Recommended Posts

Здравейте.

Изрових си от нет-а скрипт, който прави два бекъп-а (текстоеи и бинарен) и ми ги изпраща на поща.Пощата е в gmail-a.Интересното е, че миналата година всичко работеше перфектно, но от 2020 скрипта спря да работи и това е на 5 рутера.

Това е скрипта:

{
:log info "Starting Backup Script...";
:local sysname [/system identity get name];
:local sysver [/system package get system version];
:log info "Flushing DNS cache...";
/ip dns cache flush;
:delay 2;
:log info "Deleting last Backups...";
:foreach i in=[/file find] do={:if ([:typeof [:find [/file get $i name] "$sysname-backup-"]]!="nil") do={/file remove $i}};
:delay 2;
:local smtpserv [:resolve "smtp.gmail.com"];
:local Eaccount "mickrotik13@gmail.com";
:local pass "@ot1do50!#";
:local backupfile ("$sysname-backup-" . \
[:pick [/system clock get date] 7 11] . [:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6] . ".backup");
:log info "Creating new Full Backup file...";
/system backup save name=$backupfile;
:delay 2;
:log info "Sending Full Backup file via E-mail...";
/tool e-mail send from="<$Eaccount>" to=$Eaccount server=$smtpserv port=587 user=$Eaccount password=$pass start-tls=yes file=$backupfile \
subject=("$sysname Full Backup (" . [/system clock get date] . ")") \
body=("$sysname full Backup file see in attachment.\nRouterOS version: $sysver\nTime and Date stamp: " . [/system clock get time] . " " . \
[/system clock get date]);
:delay 5;
:local exportfile ("$sysname-backup-" . [:pick [/system clock get date] 7 11] . [:pick [/system \
clock get date] 0 3] . [:pick [/system clock get date] 4 6] . ".rsc");
:log info "Creating new Setup Script file...";
/export verbose file=$exportfile;
:delay 2;
:log info "Sending Setup Script file via E-mail...";
/tool e-mail send from="<$Eaccount>" to=$Eaccount server=$smtpserv port=587 user=$Eaccount password=$pass start-tls=yes file=$exportfile \
subject=("$sysname Setup Script Backup (" . [/system clock get date] . ")") body=("$sysname Setup Script file see in attachment.\nRouterOS \
version: $sysver\nTime and Date stamp: " . [/system clock get time] . " " . [/system clock get date]);
:delay 5;
:log info "All System Backups emailed successfully.\nBackuping completed.";
}

А това е планировчика:

/tool e-mail send to=mickrotik13@gmail.com subject=([/system identity get name] . "-" . [:pick [/system clock get date] 4 6] . [:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 7 11]. " backup") file=auto.backup

А най интересното е, че като рънна скрипта, той се изпълнява.

Някакви идеи?

Link to comment
Share on other sites

Работещо при мен:

/system scheduler
add interval=1w2d12m name=backup on-event="/export compact file=backup" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon start-date=\
    dec/21/2017 start-time=11:28:45
add interval=1w2d17m name="e-mail send" on-event="/tool e-mail send to=\"xxxx@xxxx.com\" subject=([/system identity get name].\" backup\") file=backup.\
    rsc;\r\
    \n:log info \"Backup e-mail sent.\"; }" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon start-date=dec/21/2017 start-time=\
    11:32:47

настройки на мейла:

/tool e-mail
set address=mail.xxxxxx.net from=xxxxxxx@xxxx.com password=xxxxxx port=587 start-tls=yes user=xxxxxxx@xxxx.com

На местата с XXXX си сложи твоите настройки. Недей забравя да настроиш и SNTP клиента !.

Интервалите и начина на архивиране (бинарен или текстови) можеш да си ги настроиш.

Това, че пише 2017 година като начална в скрипта няма никакво значение защото следващия бекъп става на актуална дата в моя случай след девет дена. И после си ги повтаря през девет дена.

 

Link to comment
Share on other sites

/tool e-mail send to=xxxxx@gmail.com subject=([/system identity get name] . "-" . [:pick [/system clock get date] 4 6] . [:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 7 11]. " backup") file=auto.backup

 

Това ми е в schedule  и работеше без проблем по този нзчин.

Link to comment
Share on other sites

Преди 1 час, prompt написа:

/tool e-mail send to=xxxxx@gmail.com subject=([/system identity get name] . "-" . [:pick [/system clock get date] 4 6] . [:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 7 11]. " backup") file=auto.backup

 

Това ми е в schedule  и работеше без проблем по този нзчин.

Замени го тогава с името на скрипта ... нали каза , че работи, като се рънне или пробвай първо само с редактиране на датата за първоначално пускане да е настояща спрямо днешна дата.

Edited by JohnTRIVOLTA
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.