Community discussions

MikroTik App
 
User avatar
mves
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 91
Joined: Tue Jan 11, 2011 8:15 pm
Location: Serbia

Backup over SSH or telnet ?

Mon Sep 12, 2011 3:53 am

Hi !
Is it possible to do a backup configuration and download backup to a hard-drive over SSH or telnet command?

Thanks
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: Backup over SSH or telnet ?

Mon Sep 12, 2011 5:03 am

Sure. First set up a private/public key pair for SSH: http://wiki.mikrotik.com/wiki/Manual:Ro ... A#SSH_Keys

Now you can do password-less logins.

Text format config backup:
ssh user@router export > configuration-file.txt
Binary format config backup:
ssh user@router "/system backup save file=backup.bak" && scp user@router:/backup.bak ./
That's assuming an OpenSSH client on the host the commands are run from, OpenSSH is available for every major OS.
 
User avatar
mves
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 91
Joined: Tue Jan 11, 2011 8:15 pm
Location: Serbia

Re: Backup over SSH or telnet ?

Mon Sep 12, 2011 2:08 pm

Hmmm, first command is usable... Second command, I don't know how to convert it for plink.
I'm using a plink.exe for that but I have no idea how to make it download configuration or at least, I don't know what command is used to download backup file. Creation of backup file would be like
plink.exe -ssh -l USER -pw PASSWORD IP  "/system backup save name=backup"
It's nicely create backup file, but now, how to download it? I'm trying to make an auto backup script that will go through all routers and pool backup but I'm stuck with download command.
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Backup over SSH or telnet ?

Mon Sep 12, 2011 3:40 pm

for second part (after &&) you can use any other file transfer available, download it using FTP, or using SFTP or even TFTP.

you can try to look up somehting like winscp, and see if that has some CLI capabilty to work w/o interface

Commands fewi gave would work on any Linux or *BSD machine (Mac OS X).
 
User avatar
mves
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 91
Joined: Tue Jan 11, 2011 8:15 pm
Location: Serbia

Re: Backup over SSH or telnet ?

Mon Sep 12, 2011 5:25 pm

for second part (after &&) you can use any other file transfer available, download it using FTP, or using SFTP or even TFTP.

you can try to look up somehting like winscp, and see if that has some CLI capabilty to work w/o interface

Commands fewi gave would work on any Linux or *BSD machine (Mac OS X).

I've tried now winscp but I can't see any option to get automatically log in and download specific file in a command mode. After manual log in, it opened something like total commander interface. Is there any other tool with command interface? Or, we'll have to wait implementing command for save file in a command line interface?

EDIT:

I've tried psftp.exe and I've got this as a result

G:\>psftp xxx.xxx.xxx.xxx -l xxxxxxxxxx -pw xxxxxxxxxxxx -batch -b bt.txt

Using username "xxxxxxxxxx".
Remote working directory is /
remote:/MikroTik-02092011-0143.backup => local:MikroTik-02092011-0143.backup
error while reading: received a short buffer from FXP_READ, but not at EOF

All downloaded files are 1.080.816 bytes. What's wrong? Is it MT issue or psftp issue? ROS is 5.6. It works on 4.17 :(
Last edited by mves on Mon Sep 12, 2011 5:59 pm, edited 2 times in total.
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: Backup over SSH or telnet ?

Mon Sep 12, 2011 5:30 pm

PuTTY offers pscp on their download page, which should work fine from the CLI.

Or, as mentioned, install OpenSSH for Windows.
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Backup over SSH or telnet ?

Tue Sep 13, 2011 11:01 am

not sure, i am using scp extensively on my Linux box and have not seen any problems while transferring files and i do that a lot.
 
User avatar
mves
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 91
Joined: Tue Jan 11, 2011 8:15 pm
Location: Serbia

Re: Backup over SSH or telnet ?

Wed Oct 12, 2011 2:30 pm

ROS 5.7 and still the same error...
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Backup over SSH or telnet ?

Thu Oct 13, 2011 12:25 pm

enable logging and create supout.rif file and send it to support@mikrotik
 
helisat
just joined
Posts: 5
Joined: Thu Nov 20, 2008 4:26 am

Re: Backup over SSH or telnet ?

Thu Jan 05, 2012 7:06 am

Hi .. just wondering if this has been resolved?

I get the same error. I am using ROS v5.11 and Filezilla SFTP Client. If I use standard FTP it works fine, but SFTP fails.

Here is a sample of the errors seen at the Filezilla Log. The file seems to eventually complete, but its corrupt. The error only seems to occur from transfers from the MT router to client, other direction works fine.


Status: Connecting to 10.10.10.1...
Response: fzSftp started
Command: open "lukesftp@10.10.10.1" 22
Command: Pass: *****
Status: Connected to 10.10.10.1
Status: Starting download of /cam3.rar
Command: cd "/"
Response: New directory is: "/"
Command: get "cam3.rar" "C:\Users\Luke\Desktop\Backup\sftp\cam3.rar"
Status: remote:/cam3.rar => local:C:\Users\Luke\Desktop\Backup\sftp\cam3.rar
Error: error while reading: received a short buffer from FXP_READ, but not at EOF
Error: File transfer failed after transferring 540,243 bytes in 1 second
Status: Starting download of /cam3.rar
Command: reget "cam3.rar" "C:\Users\Luke\Desktop\Backup\sftp\cam3.rar"
Status: reget: restarting at file position 540243
Status: remote:/cam3.rar => local:C:\Users\Luke\Desktop\Backup\sftp\cam3.rar
Error: error while reading: received a short buffer from FXP_READ, but not at EOF
Error: File transfer failed after transferring 431,237 bytes in 1 second
Status: Starting download of /cam3.rar
Command: reget "cam3.rar" "C:\Users\Luke\Desktop\Backup\sftp\cam3.rar"
Status: reget: restarting at file position 971480
Status: remote:/cam3.rar => local:C:\Users\Luke\Desktop\Backup\sftp\cam3.rar
Error: error while reading: received a short buffer from FXP_READ, but not at EOF
Error: File transfer failed after transferring 213,161 bytes in 1 second
Status: Starting download of /cam3.rar
Command: reget "cam3.rar" "C:\Users\Luke\Desktop\Backup\sftp\cam3.rar"
Status: reget: restarting at file position 1184641
Status: remote:/cam3.rar => local:C:\Users\Luke\Desktop\Backup\sftp\cam3.rar
Error: error while reading: received a short buffer from FXP_READ, but not at EOF
Error: File transfer failed after transferring 98,226 bytes in 1 second
Status: Starting download of /cam3.rar
Command: reget "cam3.rar" "C:\Users\Luke\Desktop\Backup\sftp\cam3.rar"
Status: reget: restarting at file position 1299238
Status: remote:/cam3.rar => local:C:\Users\Luke\Desktop\Backup\sftp\cam3.rar
Error: error while reading: received a short buffer from FXP_READ, but not at EOF
Error: File transfer failed after transferring 49,373 bytes in 1 second
Status: Starting download of /cam3.rar
Command: reget "cam3.rar" "C:\Users\Luke\Desktop\Backup\sftp\cam3.rar"
Status: reget: restarting at file position 1348611
Status: remote:/cam3.rar => local:C:\Users\Luke\Desktop\Backup\sftp\cam3.rar
Error: error while reading: received a short buffer from FXP_READ, but not at EOF
Error: File transfer failed after transferring 32,742 bytes in 1 second
Status: Starting download of /cam3.rar
Command: reget "cam3.rar" "C:\Users\Luke\Desktop\Backup\sftp\cam3.rar"
Status: reget: restarting at file position 1381353
Status: remote:/cam3.rar => local:C:\Users\Luke\Desktop\Backup\sftp\cam3.rar
Status: File transfer successful, transferred 16,371 bytes in 1 second


Cheers,
Luke
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Backup over SSH or telnet ?

Thu Jan 05, 2012 8:41 am

what is ticket number for this problem?

is you have not one, please enable ssh debug logging (preferably with alot of lines so whole log will fit in) and attempt this action and add log from filezilla too.
 
MikroManagement
Frequent Visitor
Frequent Visitor
Posts: 64
Joined: Thu Feb 09, 2006 2:41 pm
Location: Pretoria

Re: Backup over SSH or telnet ?

Thu Jan 05, 2012 11:57 am

Same error here.

Will post details just now
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Backup over SSH or telnet ?

Thu Jan 05, 2012 12:15 pm

there appear to be same issue with putty SFTP implementation, it seems that they share same code. If possible use openssh implementation for the time when we work on the issue.
 
helisat
just joined
Posts: 5
Joined: Thu Nov 20, 2008 4:26 am

Re: Backup over SSH or telnet ?

Thu Jan 05, 2012 5:30 pm

I created a new ticket #2012010566000601

It contains the requested debug log files.

Thanks.
 
ditonet
Forum Veteran
Forum Veteran
Posts: 835
Joined: Mon Oct 19, 2009 12:52 am
Location: Europe/Poland/Konstancin-Jeziorna
Contact:

Re: Backup over SSH or telnet ?

Fri Jan 06, 2012 10:37 pm

Just FYI:
ROS 5.11 and Filezilla SFTP, WinSCP in SFTP mode and PuTTY/psftp.exe work fine for me.

HTH,
 
helisat
just joined
Posts: 5
Joined: Thu Nov 20, 2008 4:26 am

Re: Backup over SSH or telnet ?

Sat Jan 07, 2012 12:03 pm

I have ROS 5.11 on a RB230 ..

-Doesn't work with Filezilla Client v3.5.2 (SFTP).
"error while reading: received a short buffer from RXP_READ, but not EOF"

- Not working with WinSCP (SFTP) v4.3.6.

- Not working with psftp v0.62b
"error while reading: received a short buffer from RXP_READ, but not EOF"
 
ditonet
Forum Veteran
Forum Veteran
Posts: 835
Joined: Mon Oct 19, 2009 12:52 am
Location: Europe/Poland/Konstancin-Jeziorna
Contact:

Re: Backup over SSH or telnet ?

Sat Jan 07, 2012 1:31 pm

Tested on RB433AH, ROS 5.11.
Win XP SP3, FileZilla 3.5.2, WinSCP 4.3.6, PuTTY 0.62.
Not working with psftp v0.62b
Letter 'b' means 'beta' and I noticed some bugs with this version, download latest stable version.
But FileZilla and WinSCP are latest version, probably problem is with ROS on your RB.

HTH,
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Backup over SSH or telnet ?

Tue Jan 10, 2012 2:48 pm

thank you for reports we have identified the issue and are going to work on it.
 
xeless
just joined
Posts: 2
Joined: Thu Feb 04, 2016 12:05 pm

Re: Backup over SSH or telnet ?

Thu Feb 04, 2016 12:09 pm

Hello there. I know thats an old post but we have encountered with the same problem. We tried to make an automatism which can backup our router configurations. I could login via ssh could create backup but could not save through scp nor sftp. Both say "stalled". Any idea?
 
xeless
just joined
Posts: 2
Joined: Thu Feb 04, 2016 12:05 pm

Re: Backup over SSH or telnet ?

Thu Feb 04, 2016 1:26 pm

Hello there!. We have encountered with the same or similar problem. We tried to make automatic backups of our devices. We could able to connect via ssh or sftp and make binary backups but when we were trying to get these files with scp or sftp the copy procedure was stalled about the half of the progress. Any idea?
 
User avatar
spacekcz
just joined
Posts: 5
Joined: Thu Feb 04, 2016 10:33 pm
Contact:

Re: Backup over SSH or telnet ?

Thu Feb 04, 2016 10:38 pm

I have same problem.
xxx@xxx:~$ scp rbackup@192.168.252.118:/a.backup ./
a.backup 52% 12KB 3.8KB/s - stalled -

MikrotikOS version is: 6.34

Any help ?

New result of tests: RouterOS v6.32.3 work fine, but 6.34 and 6.34.1 have problem with download via scp.
 
saiko
just joined
Posts: 1
Joined: Wed Jan 08, 2014 11:12 pm

Re: Backup over SSH or telnet ?

Sun Feb 14, 2016 11:29 pm

Full v5.xx
sshpass -p $hostpasswd ssh $hostlogin@$hostip -p $host_port "export" > $hostname"_full.rsc"
Compact v5.xx:
sshpass -p $hostpasswd ssh $hostlogin@$hostip -p $host_port "export compact" > $hostname"_compact.rsc"
 
lukkes
Member Candidate
Member Candidate
Posts: 177
Joined: Mon Jun 16, 2008 2:12 am
Location: Venezuela
Contact:

Re: Backup over SSH or telnet ?

Tue May 17, 2016 5:23 pm

I have the same problem, with one of my 16 ap, with SCP the transfer is stalled. any ideas?
thanks
 
pe1chl
Forum Guru
Forum Guru
Posts: 10195
Joined: Mon Jun 08, 2015 12:09 pm

Re: Backup over SSH or telnet ?

Tue May 17, 2016 5:51 pm

You had "mail with attachment" issues as well, didn't you?
Same cure: solve MTU and/or ICMP blocking issue. Really.
 
lukkes
Member Candidate
Member Candidate
Posts: 177
Joined: Mon Jun 16, 2008 2:12 am
Location: Venezuela
Contact:

Re: Backup over SSH or telnet ?

Tue May 17, 2016 6:56 pm

MTU in the same network segment? in a local LAN, i dont think so, also there is no firewall blocking nothing between them
and the problem it's just with one ap, other tan the email with attachment problem.

Who is online

Users browsing this forum: andrejtom and 29 guests