Community discussions

MikroTik App
 
almustaness
just joined
Topic Author
Posts: 19
Joined: Thu Feb 14, 2013 12:38 pm

I want to backup my server to my PC ? how ?

Mon Apr 08, 2013 10:08 pm

I want my server to backup tom my PC. Server give 192.168.10.0 for users. let us assume my PC took 192.168.10.2

So how can I backup to my PC IP (192.168.10.2) by using a script + scheduler ??
 
aleprolit
just joined
Posts: 18
Joined: Thu Apr 11, 2013 11:36 am

Re: I want to backup my server to my PC ? how ?

Sat Apr 13, 2013 5:17 pm

You must to install FTP server to you PC
and use this script:
# automated System  backup  to External FTP
# 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]
:set ds ([:pick $ds 7 11].[:pick $ds 0 3].[:pick $ds 4 6])
# This line to generate the file name for System backup - file name will be MY- ServerName? - Date? - Time?
:local fname ("/MY-".[/system identity get name]."-".$ds."-".$ts.".backup")
# to get unique - $filename=System Backup
/system backup save name=$fname
:log info message=SystemBackupFinished;
# Upload the System Backup to External FTP - change address to your ftp server + user + pass
/tool fetch address=[:resolve "x.x.x.x"] host="x.x.x.x" user="your user" password="your password" mode=ftp src-path="$fname" dst-path="BackUps/$fname" upload=yes
# Delay time to finish the upload - increase it if your backup file is big
:delay 60s;
# Find file name start with MY- then remove
:foreach i in=[/file find] do={:if ([:typeof [:find [/file get $i name] "MY-"]]!="nil") do={/file remove $i}}
:log info message=SystemBackup-TempRemoved;
:log info message=SystemBackup-Finished;
Or from terminal
/system script
add name=FTP-Backup policy=\
    ftp,read,write,policy,test,winbox,password,sniff,sensitive,api source="# G\
    et 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 System backup - file name will\
    \_be MY- ServerName\? - Date\? - Time\?\r\
    \n:local fname (\"/MY-\".[/system identity get name].\"-\".\$ds.\"-\".\$ts\
    .\".backup\")\r\
    \n# to get unique - \$filename=System Backup\r\
    \n/system backup save name=\$fname\r\
    \n:log info message=SystemBackupFinished;\r\
    \n# Upload the System Backup to External FTP - change address to your ftp \
    server + user + pass\r\
    \n/tool fetch address=\"x.x.x.x\" src-path=\"\$fname\" dst-path=\"Ba\
    ckUps/\$fname\" user=\"your user\" password=\"your password\" mode=ftp  uploa\
    d=yes\r\
    \n# Delay time to finish the upload - increase it if your backup file is b\
    ig\r\
    \n:delay 60s;\r\
    \n# Find file name start with MY- then remove\r\
    \n:foreach i in=[/file find] do={:if ([:typeof [:find [/file get \$i name]\
    \_\"MY-\"]]!=\"nil\") do={/file remove \$i}}\r\
    \n:log info message=SystemBackup-TempRemoved;\r\
    \n:log info message=SystemBackup-Finished;\r\
    \n"

Who is online

Users browsing this forum: No registered users and 70 guests