Page 1 of 1
Backup over SSH or telnet ?
Posted: Mon Sep 12, 2011 3:53 am
by mves
Hi !
Is it possible to do a backup configuration and download backup to a hard-drive over SSH or telnet command?
Thanks
Re: Backup over SSH or telnet ?
Posted: Mon Sep 12, 2011 5:03 am
by fewi
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.
Re: Backup over SSH or telnet ?
Posted: Mon Sep 12, 2011 2:08 pm
by mves
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.
Re: Backup over SSH or telnet ?
Posted: Mon Sep 12, 2011 3:40 pm
by janisk
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).
Re: Backup over SSH or telnet ?
Posted: Mon Sep 12, 2011 5:25 pm
by mves
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
Re: Backup over SSH or telnet ?
Posted: Mon Sep 12, 2011 5:30 pm
by fewi
PuTTY offers pscp on their download page, which should work fine from the CLI.
Or, as mentioned, install OpenSSH for Windows.
Re: Backup over SSH or telnet ?
Posted: Tue Sep 13, 2011 11:01 am
by janisk
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.
Re: Backup over SSH or telnet ?
Posted: Wed Oct 12, 2011 2:30 pm
by mves
ROS 5.7 and still the same error...
Re: Backup over SSH or telnet ?
Posted: Thu Oct 13, 2011 12:25 pm
by janisk
enable logging and create supout.rif file and send it to support@mikrotik
Re: Backup over SSH or telnet ?
Posted: Thu Jan 05, 2012 7:06 am
by helisat
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
Re: Backup over SSH or telnet ?
Posted: Thu Jan 05, 2012 8:41 am
by janisk
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.
Re: Backup over SSH or telnet ?
Posted: Thu Jan 05, 2012 11:57 am
by MikroManagement
Same error here.
Will post details just now
Re: Backup over SSH or telnet ?
Posted: Thu Jan 05, 2012 12:15 pm
by janisk
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.
Re: Backup over SSH or telnet ?
Posted: Thu Jan 05, 2012 5:30 pm
by helisat
I created a new ticket #2012010566000601
It contains the requested debug log files.
Thanks.
Re: Backup over SSH or telnet ?
Posted: Fri Jan 06, 2012 10:37 pm
by ditonet
Just FYI:
ROS 5.11 and Filezilla SFTP, WinSCP in SFTP mode and PuTTY/psftp.exe work fine for me.
HTH,
Re: Backup over SSH or telnet ?
Posted: Sat Jan 07, 2012 12:03 pm
by helisat
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"
Re: Backup over SSH or telnet ?
Posted: Sat Jan 07, 2012 1:31 pm
by ditonet
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,
Re: Backup over SSH or telnet ?
Posted: Tue Jan 10, 2012 2:48 pm
by janisk
thank you for reports we have identified the issue and are going to work on it.
Re: Backup over SSH or telnet ?
Posted: Thu Feb 04, 2016 12:09 pm
by xeless
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?
Re: Backup over SSH or telnet ?
Posted: Thu Feb 04, 2016 1:26 pm
by xeless
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?
Re: Backup over SSH or telnet ?
Posted: Thu Feb 04, 2016 10:38 pm
by spacekcz
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.
Re: Backup over SSH or telnet ?
Posted: Sun Feb 14, 2016 11:29 pm
by saiko
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"
Re: Backup over SSH or telnet ?
Posted: Tue May 17, 2016 5:23 pm
by lukkes
I have the same problem, with one of my 16 ap, with SCP the transfer is stalled. any ideas?
thanks
Re: Backup over SSH or telnet ?
Posted: Tue May 17, 2016 5:51 pm
by pe1chl
You had "mail with attachment" issues as well, didn't you?
Same cure: solve MTU and/or ICMP blocking issue. Really.
Re: Backup over SSH or telnet ?
Posted: Tue May 17, 2016 6:56 pm
by lukkes
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.