Guest User

Untitled

a guest
May 28th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. :local saveUserDB true
  2. :local saveSysBackup true
  3. :local encryptSysBackup false
  4. :local saveRawExport true
  5.  
  6. :local FTPServer "ftpserver.tld"
  7. :local FTPPort 21
  8. :local FTPUser "my-mikrotik"
  9. :local FTPPass "SecurePassword"
  10.  
  11.  
  12. :local ts [/system clock get time]
  13. :set ts ([:pick $ts 0 2].[:pick $ts 3 5].[:pick $ts 6 8])
  14.  
  15. :local ds [/system clock get date]
  16. :set ds ([:pick $ds 7 11].[:pick $ds 0 3].[:pick $ds 4 6])
  17.  
  18. :local fname ("BACKUP-".[/system identity get name]."-".$ds."-".$ts)
  19. :local sfname ("/".$fname)
  20.  
  21. :if ($saveUserDB) do={
  22. /tool user-manager database save name=($sfname.".umb")
  23. :log info message="User Manager DB Backup Finished"
  24. }
  25.  
  26. :if ($saveSysBackup) do={
  27. :if ($encryptSysBackup = true) do={ /system backup save name=($sfname.".backup") }
  28. :if ($encryptSysBackup = false) do={ /system backup save dont-encrypt=yes name=($sfname.".backup") }
  29. :log info message="System Backup Finished"
  30. }
  31.  
  32. if ($saveRawExport) do={
  33. /export file=($sfname.".rsc")
  34. :log info message="Raw configuration script export Finished"
  35. }
  36.  
  37. :local backupFileName ""
  38.  
  39. :foreach backupFile in=[/file find] do={
  40. :set backupFileName ("/".[/file get $backupFile name])
  41. :if ([:typeof [:find $backupFileName $sfname]] != "nil") do={
  42. /tool fetch address=$FTPServer port=$FTPPort src-path=$backupFileName user=$FTPUser mode=ftp password=$FTPPass dst-path=$backupFileName upload=yes
  43. }
  44. }
  45.  
  46. :delay 5s
  47.  
  48. :foreach backupFile in=[/file find] do={
  49. :if ([:typeof [:find [/file get $backupFile name] "BACKUP-"]]!="nil") do={
  50. /file remove $backupFile
  51. }
  52. }
  53.  
  54. :log info message="Successfully removed Temporary Backup Files"
  55. :log info message="Automatic Backup Completed Successfully"
Add Comment
Please, Sign In to add comment