Page 1 of 1
API /export problem
Posted: Sun Jan 18, 2009 11:06 am
by rodolfo
Hi all.
If I send an /export I receive !done
If I send an /export =file=expf.rsc, I receive !done and I found a file containing:
# jan/18/2009 09:02:58 by RouterOS 3.17
# software id = XIQI-3TT
#
/ip ipsec proposal
set default auth-algorithms=sha1 disabled=no enc-algorithms=3des lifetime=30m \
name=default pfs-group=modp1024
Wich is the correct API syntax to retrieve the export list ?
thanks
Re: API /export problem
Posted: Wed Jan 21, 2009 11:50 am
by janisk
correct syntax would be:
rsc will be added automatically, if you add rsc yourself, then the result should be filename.rsc.rsc
also, there is a little problem with export command issued over API when saving to file. export without arguments should return !done, as it is doing it now.
Re: API /export problem
Posted: Wed Jan 21, 2009 2:06 pm
by rodolfo
Sending:
returns only:
Sending:
returns:
BUT....the file created is only a small part of the full export file (98KB vs 250KB). In particular "/ppp secret" is not present.
Re: API /export problem
Posted: Wed Jan 21, 2009 2:24 pm
by janisk
this is known problem
as i wrote in my previous post:
also, there is a little problem with export command issued over API when saving to file.
we are looking into this problem, hope we get fix as soon as possible so we can get it into next release
Re: API /export problem
Posted: Thu Sep 09, 2010 5:27 am
by pdeline
Any progress on this issue. When I issues "/export =file=myconfig" from the API I get a 8600 byte file. When I issue "/export file=myconfig" from the command line (telnet or ssh), I get a 17215 byte file.
Re: API /export problem
Posted: Mon Nov 01, 2010 5:02 am
by archerfish
Have the same problem, any progress?
Re: API /export problem
Posted: Wed Mar 20, 2013 5:40 pm
by mysz0n
question. when i execute this command:
$API->write('/export', false);
$API->write('=file=test_from_API.rsc', true);
$A = $API->read();
I get file exported to Mikrotik
how can I catch and save the contents of the file into the database? can API send exported content as a response like it does with e.g.
$API->write('/interface/bridge/filter/getall',true);
?
Re: API /export problem
Posted: Fri Nov 22, 2013 10:02 pm
by eugenevdm
This is a really old post but I have the similar question.
When you press the "Backup" button in Winbox it generates a 52.1 KiB file.
When I use the API as such:
I get a 10.8 KiB file called "Backup.rsc". Clearly some information is missing?
That begs the question, how to do you backup using the API?
Re: API /export problem
Posted: Sat Nov 23, 2013 3:39 am
by Chupaka
backup and export are completely different things. /export is just text config of the router, w/o any history data like graphing.
2
mysz0n: yesterday I started a ticket about getting file contents when file size is greater that 4095 bytes. hope it will end successfully
Re: API /export problem
Posted: Mon Nov 25, 2013 5:16 pm
by eugenevdm
backup and export are completely different things. /export is just text config of the router, w/o any history data like graphing.
Great thanks for clarifying.
1. When our routers crash will it be safe to just restore the .rsc if we are not interested in the graphs?
2. Apart from graphs, what else is not backed up? Presumably the httpdocs?
> how to do you backup using the API?
The answer to this question is still of interest to me.
Re: API /export problem
Posted: Mon Nov 25, 2013 6:02 pm
by boen_robot
2. Apart from graphs, what else is not backed up? Presumably the httpdocs?
You may want to brush up your use of terminology...
The
configuration is
exported, the
system is
backup-ed.
So... when you do export, the file system in general, be it HTTP docs or just script files laying around, won't be exported. Also, passwords and modules.
A backup AFAIK includes also files, passwords and modules, but is intended to be restored on the same system (except, potentially, a new HDD). In contrast, an export can be used on a different system, and a different version even, as long as the commands used are compatible.
> how to do you backup using the API?
The answer to this question is still of interest to me.
Following the CLI command:
/system/backup/save
=name=backupFileName
And for exporting, you have the syntax shown above.
Re: API /export problem
Posted: Fri Aug 03, 2018 1:08 pm
by 007mira
Is there any progress with API and export? We have PHP side where we would like to send / export... and download via FTP afterwards, but very often we receive onyl file with interrupted lines.
Or, Is there any process how to reach full export?
Thank you
Re: API /export problem
Posted: Sat Aug 04, 2018 6:11 pm
by boen_robot
Is there any progress with API and export? We have PHP side where we would like to send / export... and download via FTP afterwards, but very often we receive onyl file with interrupted lines.
Or, Is there any process how to reach full export?
Thank you
You could use PHP to create a scheduler script that does /export after a second or so, and removes itself. The fact that it will be the scheduler that does it (rather than the API) will create a proper file that you can then download with FTP.
Re: API /export problem
Posted: Tue Aug 07, 2018 11:03 am
by philately
Hey guys,
Is there really no way to retrieve the running-config from a RouterOS device without first writing the file out to disk?
I want to use the API to schedule a regular export of the configuration from all my devices, but writing to disk every time is going to burn out my flash.
Re: API /export problem
Posted: Tue Aug 07, 2018 11:49 am
by nescafe2002
I moved from API to SSH since API exports are not ROS compatible (yes/no <=> true/false).
Redirect the ssh output to a file, no intermediate write to flash necessary.
$ ssh admin@router.lan /export > config.rsc
Re: API /export problem
Posted: Fri Aug 17, 2018 10:54 pm
by madmouser1
Hi all,
Is there any traction or a resolution found for this? I would like to ultimately use napalm to retrieve the config thus it must be via Python API and not another workaround.
Thanks
Re: API /export problem
Posted: Tue Sep 04, 2018 2:18 pm
by antonsb
what about paramiko?
import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('192.168.88.1', port=22, username='admin', password='')
stdin, stdout, stderr = client.exec_command('export')
for line in stdout:
print(line.strip('\n'))
client.close()