API /export problem

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

correct syntax would be:

/export
=file=expf

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.

Sending:

/export

returns only:

!done

Sending:

/export =file=apiex

returns:

!done

BUT…the file created is only a small part of the full export file (98KB vs 250KB). In particular “/ppp secret” is not present.

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

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.

Have the same problem, any progress?

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);

?

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:

/export
=file=backup

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?

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 :slight_smile:

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.

  1. 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.

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.

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.

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

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

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()