mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2024-05-11 05:55:19 +00:00
email-backup: work inside directory
This commit is contained in:
18
email-backup
18
email-backup
@ -22,6 +22,7 @@
|
|||||||
:global CharacterReplace;
|
:global CharacterReplace;
|
||||||
:global DeviceInfo;
|
:global DeviceInfo;
|
||||||
:global LogPrintExit2;
|
:global LogPrintExit2;
|
||||||
|
:global MkDir;
|
||||||
:global RandomDelay;
|
:global RandomDelay;
|
||||||
:global ScriptFromTerminal;
|
:global ScriptFromTerminal;
|
||||||
:global WaitForFile;
|
:global WaitForFile;
|
||||||
@ -42,26 +43,31 @@ $WaitFullyConnected;
|
|||||||
$RandomDelay $BackupRandomDelay;
|
$RandomDelay $BackupRandomDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:if ([ $MkDir $0 ] = false) do={
|
||||||
|
$LogPrintExit2 error $0 ("Failed creating directory!") true;
|
||||||
|
}
|
||||||
|
|
||||||
# filename based on identity
|
# filename based on identity
|
||||||
:local FileName [ $CharacterReplace ($Identity . "." . $Domain) "." "_" ];
|
:local FileName [ $CharacterReplace ($Identity . "." . $Domain) "." "_" ];
|
||||||
|
:local FilePath ($0 . "/" . $FileName);
|
||||||
:local BackupFile "none";
|
:local BackupFile "none";
|
||||||
:local ConfigFile "none";
|
:local ConfigFile "none";
|
||||||
:local Attach [ :toarray "" ];
|
:local Attach [ :toarray "" ];
|
||||||
|
|
||||||
# binary backup
|
# binary backup
|
||||||
:if ($BackupSendBinary = true) do={
|
:if ($BackupSendBinary = true) do={
|
||||||
/ system backup save encryption=aes-sha256 name=$FileName password=$BackupPassword;
|
/ system backup save encryption=aes-sha256 name=$FilePath password=$BackupPassword;
|
||||||
$WaitForFile ($FileName . ".backup");
|
$WaitForFile ($FilePath . ".backup");
|
||||||
:set BackupFile ($FileName . ".backup");
|
:set BackupFile ($FileName . ".backup");
|
||||||
:set Attach ($Attach, $BackupFile);
|
:set Attach ($Attach, ($FilePath . ".backup"));
|
||||||
}
|
}
|
||||||
|
|
||||||
# create configuration export
|
# create configuration export
|
||||||
:if ($BackupSendExport = true) do={
|
:if ($BackupSendExport = true) do={
|
||||||
/ export terse file=$FileName;
|
/ export terse file=$FilePath;
|
||||||
$WaitForFile ($FileName . ".rsc");
|
$WaitForFile ($FilePath . ".rsc");
|
||||||
:set ConfigFile ($FileName . ".rsc");
|
:set ConfigFile ($FileName . ".rsc");
|
||||||
:set Attach ($Attach, $ConfigFile);
|
:set Attach ($Attach, ($FilePath . ".rsc"));
|
||||||
}
|
}
|
||||||
|
|
||||||
# send email with status and files
|
# send email with status and files
|
||||||
|
Reference in New Issue
Block a user