Mikrotik routerboard backup using SFTP

Discussion in 'General Computer Support' started by muhamed, Nov 7, 2012.

  1. muhamed

    muhamed

    Joined:
    Nov 7, 2012
    Messages:
    1
    Hello guys, i have problem with this code. I'm tryin to get backup file from Mikrotik routerboards using following code. But when run this code "10: Resource temporarily unavailable" error appeared. Someone help me pls
    package main;

    import java.util.Properties;
    import com.jcraft.jsch.*;
    import com.jcraft.jsch.ChannelSftp;
    import com.jcraft.jsch.Channel;


    public class Main {

    public static void main(String args[])
    {
    String host = "ip address";
    String username = "admin";
    String password = "pass";
    String command = "system backup save name=backup_name";
    String rfile = "backup_name.backup";
    String ftpRemoteDirectory = "/files/";
    int port = 22;

    try{
    JSch jsch = new JSch();
    Session session = jsch.getSession(username, host, port);
    session.setPassword(password);
    java.util.Properties config = new java.util.Properties();
    config.put("StrictHostKeyChecking", "no");
    session.setConfig(config);
    System.out.println("connecting...");
    session.connect();
    System.out.println("connected.");

    Channel channel = session.openChannel("exec");
    ((ChannelExec)channel).setCommand(command);
    channel.connect();

    Channel cp_channel = session.openChannel("sftp");
    cp_channel.connect();
    ChannelSftp sftpChannel = (ChannelSftp)cp_channel;
    sftpChannel.get("../file/2012/11/backup_name.backup", "D:/backup_name.backup");
    sftpChannel.exit();
    cp_channel.connect();
    channel.disconnect();
    cp_channel.disconnect();
    session.disconnect();

    }
    catch(Exception e)
    {
    System.err.print(e);
    }


    }


    }
    muhamed, Nov 7, 2012
    #1
    1. Advertising

  2. muhamed

    Jazz555

    Joined:
    Jan 23, 2013
    Messages:
    1
    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.
    Jazz555, Jan 23, 2013
    #2
    1. Advertising

  3. muhamed

    pondshus2

    Joined:
    Oct 25, 2013
    Messages:
    3
    I think the loop is not global or it is out of scope. If you can make it available to the calling function then maybe the source code can generate from it. just check up with every loops in your code and you will be good to go.




    Thanks
    Pondshus2
    Last edited: Mar 3, 2014
    pondshus2, Oct 25, 2013
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Irony Alert

    SFTP

    Irony Alert, Apr 16, 2004, in forum: Computer Support
    Replies:
    0
    Views:
    874
    Irony Alert
    Apr 16, 2004
  2. jg

    freeware SFTP utility ?

    jg, Jun 20, 2004, in forum: Computer Security
    Replies:
    5
    Views:
    3,236
    midia
    Jun 21, 2004
  3. K.J. 44
    Replies:
    10
    Views:
    16,221
    Lutz Donnerhacke
    Jan 10, 2007
  4. vbMark

    SFTP via SSHWindows/OpenSSH qustion.

    vbMark, Mar 6, 2006, in forum: Computer Support
    Replies:
    1
    Views:
    671
  5. fonestar

    Anyone here familiar with Mikrotik RouterOS?

    fonestar, Jan 10, 2011, in forum: General Computer Support
    Replies:
    0
    Views:
    1,423
    fonestar
    Jan 10, 2011
Loading...

Share This Page