-
کاربر عادی
Auto mikrotik backup
سلام
من واسه هر روتر از طریق system scheduler و با سکریپت system backup save با interval هفت روزه تنظیم کردم که اتوماتیک بکاپ گرفته بشه ولی انقدر تعداد روترها زیاد شده که نیاز هست بکاپ ها از طریق ftp و یا .... تنظیم بشه که روی یک سرور به صورت اتوماتیک هر هفته گذاشته بشن
ممنون میشم کمکم کنید .
-
2016/12/31 01:09 PM
# ADS
Circuit advertisement
-
کاربر عادی
/system scheduler
add interval=2m name=backup on-event="/system script run number=backup"
/system script
# automated backup 2 External ftp
# ftp configuration
:local ftppassword "PASSWORD"
:local ftphost "IP_ADDRESS"
:local ftpuser "FTP_USER"
:local ftppath "/FTP_DIRECTORY"
:local months ("jan","feb","mar","apr","may","jun","jul","aug"," sep","oct","nov","dec");
# months array
# get time
:local ts [/system clock get time]
:local ds [/system clock get date]
:set ts ([:pick $ts 0 2].[:pick $ts 3 5].[:pick $ts 6 8])
# get Date
# convert name of month to number
:if ($mm < 10) do={ :set mm ("0" . $mm); }
:local month [ :pick $ds 0 3 ];
:local mm ([ :find $months $month -1 ] + 1);
# set $ds to format YYYY-MM-DD
# file name for user manager backup - file name will be Auto-Backup-servername-date-time.umb
:set ds ([:pick $ds 7 11] . $mm . [:pick $ds 4 6])
:local fname ("/Auto-Backup-".[/system identity get name]."-".$ds."-".$ts.".umb")
:local fname1 ("/Auto-Backup-".[/system identity get name]."-".$ds."-".$ts.".backup")
# file name for system backup - file name will be Auto-Backup-servername-date-time.backup
# file name for config export - file name will be Auto-Backup-servername-date-time.rsc
/system backup save name=$fname1
:local fname2 ("/Auto-Backup-".[/system identity get name]."-".$ds."-".$ts.".rsc")
# backup the data
/tool user-manager database save name=$fname
:log info message="System backup finished (2/3).";
:log info message="User manager backup finished (1/3).";
/tool fetch address="$ftphost" src-path=$fname user="$ftpuser" mode=ftp password="$ftppassword" dst-path="$ftppath/$fname" upload=yes
/export compact file=$fname2
:log info message="Config export finished (3/3)."
# upload the user manager backup
:log info message="Uploading user manager backup (1/3)."
# upload the system backup
:log info message="Uploading system backup (2/3)."
/tool fetch address="$ftphost" src-path=$fname2 user="$ftpuser" mode=ftp password="$ftppassword" dst-path="$ftppath/$fname2" upload=yes
/tool fetch address="$ftphost" src-path=$fname1 user="$ftpuser" mode=ftp password="$ftppassword" dst-path="$ftppath/$fname1" upload=yes
# upload the config export
:log info message="Uploading config export (3/3)."
# find file name start with Auto-Backup- then remove
# delay time to finish the upload - increase it if your backup file is big
:delay 60s;
:log info message="Configuration backup finished.";
:foreach i in=[/file find] do={ :if ([:typeof [:find [/file get $i name] "Auto-Backup-"]]!="nil") do={/file remove $i}; }
علاقه مندی ها (Bookmarks)