Community discussions

 
rodolfo
Long time Member
Long time Member
Topic Author
Posts: 539
Joined: Sat Jul 05, 2008 11:50 am

API /export problem

Sun Jan 18, 2009 11:06 am

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
rodolfo
IZ0UQV
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6283
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: API /export problem

Wed Jan 21, 2009 11:50 am

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.
 
rodolfo
Long time Member
Long time Member
Topic Author
Posts: 539
Joined: Sat Jul 05, 2008 11:50 am

Re: API /export problem

Wed Jan 21, 2009 2:06 pm

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.
rodolfo
IZ0UQV
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6283
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: API /export problem

Wed Jan 21, 2009 2:24 pm

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
 
pdeline
just joined
Posts: 11
Joined: Thu Sep 09, 2010 5:14 am

Re: API /export problem

Thu Sep 09, 2010 5:27 am

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.
 
archerfish
just joined
Posts: 13
Joined: Wed Apr 22, 2009 8:18 am

Re: API /export problem

Mon Nov 01, 2010 5:02 am

Have the same problem, any progress?
 
mysz0n
Member Candidate
Member Candidate
Posts: 125
Joined: Tue Mar 03, 2009 2:14 am

Re: API /export problem

Wed Mar 20, 2013 5:40 pm

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);
?
 
User avatar
eugenevdm
Member Candidate
Member Candidate
Posts: 208
Joined: Tue Jun 01, 2004 12:23 pm
Location: Stellenbosch, South Africa
Contact:

Re: API /export problem

Fri Nov 22, 2013 10:02 pm

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?
The Snowball Effect
Superior Internet Solutions
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8308
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: API /export problem

Sat Nov 23, 2013 3:39 am

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 :)
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
User avatar
eugenevdm
Member Candidate
Member Candidate
Posts: 208
Joined: Tue Jun 01, 2004 12:23 pm
Location: Stellenbosch, South Africa
Contact:

Re: API /export problem

Mon Nov 25, 2013 5:16 pm

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.
The Snowball Effect
Superior Internet Solutions
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2411
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: API /export problem

Mon Nov 25, 2013 6:02 pm

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.
PEAR2_Net_RouterOS(1.0.0b6) - My API client in PHP
(Rate my posts? If you want... no pressure...)
 
007mira
just joined
Posts: 2
Joined: Fri Apr 06, 2018 8:33 am

Re: API /export problem

Fri Aug 03, 2018 1:08 pm

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
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2411
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: API /export problem

Sat Aug 04, 2018 6:11 pm

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.
PEAR2_Net_RouterOS(1.0.0b6) - My API client in PHP
(Rate my posts? If you want... no pressure...)
 
philately
just joined
Posts: 1
Joined: Tue Aug 07, 2018 10:19 am

Re: API /export problem

Tue Aug 07, 2018 11:03 am

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.
 
nescafe2002
Long time Member
Long time Member
Posts: 622
Joined: Tue Aug 11, 2015 12:46 pm
Location: Netherlands

Re: API /export problem

Tue Aug 07, 2018 11:49 am

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
 
User avatar
madmouser1
just joined
Posts: 3
Joined: Sun Jan 08, 2017 7:27 pm

Re: API /export problem

Fri Aug 17, 2018 10:54 pm

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
 
antonsb
MikroTik Support
MikroTik Support
Posts: 195
Joined: Sun Jul 24, 2016 3:12 pm
Location: Riga, Latvia

Re: API /export problem

Tue Sep 04, 2018 2:18 pm

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

Who is online

Users browsing this forum: No registered users and 10 guests