1
Sítě / Re:Skript pro zálohování MikroTiku
« kdy: 22. 06. 2023, 14:33:42 »
ArmorCZ mockrát děkuju, to je přesně to co jsem hledal, zbytek si už upravím.
Všem děkuju za pomoc.
Všem děkuju za pomoc.
Tato sekce Vám umožňuje zobrazit všechny příspěvky tohoto uživatele. Prosím uvědomte si, že můžete vidět příspěvky pouze z oblastí Vám přístupných.
:local files {$backupconf;$backuplog}
/tool e-mail send to="vvs@somewhere.com" subject="$[/system identity get name]-$[/system clock get time] Backup Configuration & Log - SBB-Optic" file=$files
# file name for system backup - file name will be Date-time-identity.backup
:local fname1 ("/".$ds."-".$ts."-".[/system identity get name].".backup")
# file name for config export - file name will be Date-time-identity.rsc
:local fname2 ("/".$ds."-".$ts."-".[/system identity get name].".rsc")
/system backup save name=$fname1
:log info message="auto_backup: System backup finished (1/2).";
/export compact file=$fname2
:log info message="auto_backup: Config export finished (2/2)."
:local files {$fname1;$fname2}
# send system backup to email
/tool e-mail send to="$emailn" subject="$[/system identity get name] - Auto Backup firmware" body="Backup files attached in this email" file=$files
:log info message="auto_backup: Sending email backup complete."
# file name for system backup - file name will be Date-time-identity.backup
:local fname1 ("/".$ds."-".$ts."-".[/system identity get name].".backup")
# file name for config export - file name will be Date-time-identity.rsc
:local fname2 ("/".$ds."-".$ts."-".[/system identity get name].".rsc")
/system backup save name=$fname1
:delay 12s
:log info message="auto_backup: System backup finished (1/2).";
/export compact file=$fname2
:delay 12s
:log info message="auto_backup: Config export finished (2/2)."
# send system backup to email
/tool e-mail send to="$emailb" subject="$[/system identity get name] - Auto Backup firmware" body="Backup files attached in this email." file=$fname1; $fname2
# file name for system backup - file name will be Date-time-identity.backup
:local fname1 ("/".$ds."-".$ts."-".[/system identity get name].".backup")
# file name for config export - file name will be Date-time-identity.rsc
:local fname2 ("/".$ds."-".$ts."-".[/system identity get name].".rsc")
/system backup save name=$fname1
:log info message="auto_backup: System backup finished (1/2).";
/export compact file=$fname2
:log info message="auto_backup: Config export finished (2/2)."
# send system backup to email
:local files {$fname1;$fname2}
/tool e-mail send to="$emailb" subject="$[/system identity get name] - Auto Backup firmware" body="Backup files attached in this email." file=$files
########## script for automatic backup to ftp v 2.0
:local date [/system clock get date]
:local day [:pick $date 4 6]
# notification e-mail
:local emailn "notifikacni email"
# backup e-mail
:local emailb "email pro zalohovani"
# months array
:local months ("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");
# get time
:local ts [/system clock get time]
:set ts ([:pick $ts 0 2].[:pick $ts 3 5].[:pick $ts 6 8])
# get Date
:local ds [/system clock get date]
# convert name of month to number
:local month [ :pick $ds 0 3 ];
:local mm ([ :find $months $month -1 ] + 1);
:if ($mm < 10) do={ :set mm ("0" . $mm); }
# set $ds to format YYYY-MM-DD
:set ds ([:pick $ds 7 11] . $mm . [:pick $ds 4 6])
# file name for system backup - file name will be Date-time-identity.backup
:local fname1 ("/".$ds."-".$ts."-".[/system identity get name].".backup")
# file name for config export - file name will be Date-time-identity.rsc
:local fname2 ("/".$ds."-".$ts."-".[/system identity get name].".rsc")
/system backup save name=$fname1
:log info message="auto_backup: System backup finished (1/2).";
/export compact file=$fname2
:log info message="auto_backup: Config export finished (2/2)."
:local files {$backupconf;$backuplog}
# send system backup to email
:local files {$fname1;$fname2}
/tool e-mail send to="$emailb" subject="$[/system identity get name] - Auto Backup firmware" body="Backup files attached in this email." file=$files
:log info message="auto_backup: Sending email backup complete."
# delay time to finish the upload - increase it if your backup file is big
:delay 1s;
# find file name start with -then remove
:foreach i in=[/file find] do={ :if ([:typeof [:find [/file get $i name] [/system identity get name]]]!="nil") do={/file remove $i}; }
:log info message="auto_backup: Configuration backup finished.";
:delay 1s;
/tool e-mail send to="$emailn" subject="$[/system identity get name] - Auto Backup firmware is finished" body="Automatic backup was completed. The backup send to $emailb."
:log info message="auto_backup: Send email about job completion."
}