[API] Bug report - export command

Hi,

I’ve just stumbled upon a bug regarding export command and wireless interfaces. Confirmed over several routers and several software versions, mostly v3.30 and v4.x. Didn’t test on v5.x

When I type /export file=somename from New Terminal window in console wireless settings are exported ok. Example:

# jun/02/2011 11:36:14 by RouterOS 3.30
# software id = I6MH-JZX3
#
/interface bridge
add admin-mac=00:00:00:00:00:00 ageing-time=5m arp=enabled auto-mac=yes \
    comment="" disabled=no forward-delay=15s l2mtu=2304 max-message-age=20s \
    mtu=1500 name=bridge1 priority=0x8000 protocol-mode=none \
    transmit-hold-count=6
/interface ethernet
set 0 arp=enabled auto-negotiation=yes cable-settings=default comment="" \
    disable-running-check=yes disabled=no full-duplex=yes mac-address=\
    00:1D:7D:BA:91:8C mtu=1500 name=ether1 speed=100Mbps
/interface wireless security-profiles
set default authentication-types="" eap-methods=passthrough group-ciphers="" \

But when I execute same command using API there is no /interface wireless subtree, example:

# jun/02/2011 12:02:54 by RouterOS 3.30
# software id = I6MH-JZX3
#
/interface bridge
add admin-mac=00:00:00:00:00:00 ageing-time=5m arp=enabled auto-mac=yes \
    comment="" disabled=no forward-delay=15s l2mtu=2304 max-message-age=20s \
    mtu=1500 name=bridge1 priority=0x8000 protocol-mode=none \
    transmit-hold-count=6
/interface ethernet
set 0 arp=enabled auto-negotiation=yes cable-settings=default comment="" \
    disable-running-check=yes disabled=no full-duplex=yes mac-address=\
    00:1D:7D:BA:91:8C mtu=1500 name=ether1 speed=100Mbps
/interface
set wlan3 comment=\

On the examples you can clearly see that after /interface ethernet there is no /interface wireless.

Is there a bug fix for this?

will check this.

I think this is a quite old bug. See this thread from 2009: http://forum.mikrotik.com/t/api-export-problem/25919/1

I have the same problem, too. When I run /export using API, many sections are ignored.

Still appears that we cannot grab an export via API, which is quite unfortunate.

If anyone else out there is trying to find a way to grab export remotely from a linux server, check into expect. I cobbled this together, which is working for me.

#!/usr/bin/expect -f
#
# USAGE: get_export.exp IP USER PASS DIRECTORY

set timeout 60
set IP [lindex $argv 0]
set USER [lindex $argv 1]
set PASS [lindex $argv 2]
set DIR [lindex $argv 3]
set DATE [exec date +%Y%m%d%H%M%S]
set PATH "/tmp/exports"
set FILE "$PATH/$DIR/$DATE"
#turn off interactive messages
log_user 0

spawn ssh -l $USER $IP
match_max 100000
expect {
        "Are you sure you want to continue connecting (yes/no)? " {
                send -- "yes\r" ; exp_continue
        }
        "assword: " {
                send -- "$PASS\r"
        }
}
expect ">"
#Start logging
log_file -a $FILE
send -- "export\r"
expect "\r\r\r"
#Stop logging
log_file
send -- "quit\r"
expect eof
puts "\r\n"
exit

for SSH, we simply add public RSA key file to the routers, then

ssh backup@$addr /export | sed '1s/^#.*RouterOS/# RouterOS/'

(where ‘sed’ removes timestamp from config, so that SVN won’t worry each time :slight_smile:)