Import / Export problem

Hi Guys, im trying to do the following (on RouterOS 5.20):

I’ve created 2 scripts con Router A:

Script 1:

/ip hotspot user export file=users
/ip hotspot ip-binding export file=bindings

Script 2:

/tool fetch address=192.168.33.XXX src-path=users.rsc user=admin mode=ftp password=XXXXXX dst-path=users.rsc upload=yes
/tool fetch address=192.168.33.XXX src-path=bindings.rsc user=admin mode=ftp password=XXXXXX dst-path=bindings.rsc upload=yes

I’ve loaded this scripts on a scheduler and its working OK.

Now, no router B i’m trying to just import the files and i’m getting this error:

[admin@MikroTik] > import users
Opening script file users.rsc

Script file loaded successfullyfailure: user profile with such name already exists

Why is this? is there something i’m doing wrong?

Analyze your ‘users’ export script file, first three lines probably looks like this:
/ip hotspot user profile
set [ find default=yes ] idle-timeout=none keepalive-timeout=2m name=default shared-users=unlimited status-autorefresh=1m transparent-proxy=no
add idle-timeout=none keepalive-timeout=2m name=trial shared-users=20 status-autorefresh=1m transparent-proxy=noThis code tries to add ‘trial’ user profile, but this profile already exists, hence error message:

user profile with such name already exists

Remove these line from .rsc file before importing.

HTH,

edit: in sentence ‘This code tries to add ‘trial’ user profile…’ was ‘default’ instead of ‘trial’

I check the code and this are the first two entries:

/ip hotspot user profile
set [ find default=yes ] address-pool=192.168.88.0 idle-timeout=none \
    keepalive-timeout=1d name=default session-timeout=1d shared-users=3 \
    status-autorefresh=1m transparent-proxy=no
add address-pool="Full(lan+vtr)" idle-timeout=none keepalive-timeout=2m name=\
    "Full(vtr+lan)" session-timeout=1d shared-users=5 status-autorefresh=1m \
    transparent-proxy=no

The one that gets the error is the second one (I added them on a terminal window).

The thing is, the first time it imports ok, but then i wanna import it again for the new ones added (users) and then it gets me the error.

The idea is to replicate the users created on Router A to Router B with scripts and scheduler… I don’t want to do it file by file I want it to be automatic.

I don’t want to do it file by file I want it to be automatic.

So your scheduled script should remove all user profiles before importing.

HTH,

Is there a way to remove all users profiles at once?

I see the command “remove” only allows me to select one item.

/ip hotspot user profile>
remove [find name=your_profile_name]This code will remove profile named ‘your_profile_name’,
but remember ‘default’ profile can not be removed, so don’t use it.

HTH,

So there’s no way to delete them all except default?

Or a way to import configurations overwriting the old ones?

EDIT: I’ve find this command that lets met erase all users at once:

/ip hotspot user remove [/ip hotspot user find]

So i could be running that on a script followed by the one importing all of them again and that would make the effect of “updating” them.

On the other hand i’ve tried this:

/ip hotspot user profile remove [/ip hotspot user profile find]

It doesnt work 'cause i can’t erase the default one… So, how can I modify the second command to just let me erase everything besides the default one?

EDIT N°2: So.. i think i’ve got it…

This is the script i’ve come up with:

/ip hotspot user remove [/ip hotspot user find]
/ip hotspot user profile remove [/ip hotspot user profile find name !=default]
/ip hotspot ip-binding remove [/ip hotspot ip-binding find]
/import users.rsc
/import bindings.rsc

This along side with some scheduling allows me to replicate hotspot users, profiles and bindings in all the routers that I have in operation just modificating the “master” one. It’s really weird that an overwrite option for import is not there, it would be very useful.

Anyways, I hope this is useful for someone. Thanks for the replies.