bem tenho procurado uma solução pra automatizar a transferência dos bkp mikrotik Via ftp
achei dois script gostaria que a galera desse uma olhada e tirasse algumas duvidas
/system script
add name=FTP-Backup policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive source="# automated System - UM database backup 2 External FTP\r\
\n# Get time\r\
\n:local ts [/system clock get time]\r\
\n:set ts ([:pick \$ts 0 2].[:pick \$ts 3 5].[:pick \$ts 6 8])\r\
\n# Get Date\r\
\n:local ds [/system clock get date]\r\
\n:set ds ([:pick \$ds 7 11].[:pick \$ds 0 3].[:pick \$ds 4 6])\r\
\n# This line to generate the file name for user manager backup - file name will be UMDB- ServerName\? - Date\? - Time\?\r\
\n:local fname (\"/UMDB-\".[/system identity get name].\"-\".\$ds.\"-\".\$ts.\".umb\")\r\
\n# This line to generate the file name for System backup - file name will be UMDB- ServerName\? - Date\? - Time\?\r\
\n:local fname1 (\"/UMDB-\".[/system identity get name].\"-\".\$ds.\"-\".\$ts.\".backup\")\r\
\n# all above is workaround to get unique \$filename=UserManagerDB - \$filename1=System\r\
\n/tool user-manager database save name=\$fname\r\
\n:log info message=UserManagerBackupFinished;\r\
\n/system backup save name=\$fname1\r\
\n:log info message=SystemBackupFinished;\r\
\n# Upload the UserManagerDB Backup to External FTP - change address to your ftp server + user + pass\r\
\n/tool fetch address=ip ftp src-path=\$fname user=use mode=ftp password=senha dst-path=/ upload=yes\r\
\n# Upload the System Backup to External FTP - change address to your ftp server + user + pass\r\
\n/tool fetch address=ip ftp src-path=\$fname1 user=use mode=ftp password=senha dst-path=/ upload=yes\r\
\n# Delay time to finish the upload - increase it if your backup file is big\r\
\n:delay 60s;\r\
\n# Find file name start with UMDB- then remove\r\
\n:foreach i in=[/file find] do={:if ([:typeof [:find [/file get \$i name] \"UMDB-\"]]!=\"nil\") do={/file remove \$i}}\r\
\n:log info message=UserMangerBackup-SystemBackup-TempRemoved;\r\
\n:log info message=UserManger-SystemBackup2CentOS-Finished;"
tem esse também
# automated backup 2 External ftp
# ftp configuration
:local ftphost "<<IP FTP>>"
:local ftpuser "<<USE>>"
:local ftppassword "<<PASSWORD>>"
:local ftppath "<<FTP PACH>>"
# 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 user manager backup - file name will be UMDB-servername-date-time.umb
:local fname ("/UMDB-".[/system identity get name]."-".$ds."-".$ts.".umb")
# file name for system backup - file name will be UMDB-servername-date-time.backup
:local fname1 ("/UMDB-".[/system identity get name]."-".$ds."-".$ts.".backup")
# file name for config export - file name will be UMDB-servername-date-time.rsc
:local fname2 ("/UMDB-".[/system identity get name]."-".$ds."-".$ts.".rsc")
# backup the data
/tool user-manager database save name=$fname
:log info message="User manager backup finished (1/3).";
/system backup save name=$fname1
:log info message="System backup finished (2/3).";
/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)."
/tool fetch address="$ftphost" src-path=$fname user="$ftpuser" mode=ftp password="$ftppassword" dst-path="$ftppath/$fname" upload=yes
# upload the system backup
:log info message="Uploading system backup (2/3)."
/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)."
/tool fetch address="$ftphost" src-path=$fname2 user="$ftpuser" mode=ftp password="$ftppassword" dst-path="$ftppath/$fname2" upload=yes
# delay time to finish the upload - increase it if your backup file is big
:delay 60s;
# find file name start with UMDB- then remove
:foreach i in=[/file find] do={ :if ([:typeof [:find [/file get $i name] "UMDB-"]]!="nil") do={/file remove $i}; }
:log info message="Configuration backup finished.";
FONTE:
http://forum.mikrotik.com/viewtopic.php?f=9&t=52371
http://int21.wordpress.com/2014/02/21/script-para-enviar-backup-do-mikrotik-para-ftp/
Respostas