Backup over SSH or telnet ?

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

Thanks

Sure. First set up a private/public key pair for SSH: http://wiki.mikrotik.com/wiki/Manual:Router_AAA#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.

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.

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

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

Or, as mentioned, install OpenSSH for Windows.

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.

ROS 5.7 and still the same error…

enable logging and create supout.rif file and send it to support@mikrotik

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

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.

Same error here.

Will post details just now

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.

I created a new ticket #2012010566000601

It contains the requested debug log files.

Thanks.

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

HTH,

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”

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,

thank you for reports we have identified the issue and are going to work on it.

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?

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?