8

I want to restore a sqlserver db backup on remote windows server from linux. I tired "net rpc" but there is nothing for execute a command or script on remote server.

1
  • SqlCmd -E -S MyServer –Q “RESTORE DATABASE [MyDB] FROM DISK=’D:sqlserverDB.bak’” | net rpc shell -I IPADDRESS -U USERNAME%PASSWORD Does anyone know this way I can execute the restore command on the remote windows server with net rpc?
    – BioLounge
    Oct 11, 2011 at 12:04

4 Answers 4

5

Check out winexe - it depends on samba, uses RPC to run remote commands and might even come with your distribution's packages.

Edit: even if your distro does not have it precompiled and you do not want to compile yourself, you should check out the Build Service - it is likely to have the binary version you would need for your system.

2
  • The dependency appears to be Samba4, not Samba(3).
    – Sven
    Oct 11, 2011 at 9:19
  • Possible. We use a statically compiled version for several years now without running Samba4 - it works.
    – the-wabbit
    Oct 11, 2011 at 9:21
4

As others have suggested elsewhere, you can setup an ssh server on the win box with cygwin and run .bat or .cmd files remotely that way.

0
2

You haven't really described what you want done or how often you want it done.

If what you want done is repetitive and parameterizable you can use the age old solution of creating a daemon on the remote server that periodically checks for file entries in a shared directory, where the file entries contain the parameters for the script. That's how print servers and many other daemons first worked. If you do it that way then regular old windows scheduled tasks, batch files, and shared directories will take you far.

The modern version (and perhaps much more overkill) of that of course is to create a simple webserver on the windows machine that performs your db restore task whenever someone requests the appropriate url.

1

You can start the Telnet service on the Windows server and then run the command through a Telnet session.

10
  • 4
    Obligatory warning: Telnet is completely unencrypted, everything you type goes over the wire in clear text.
    – Sven
    Oct 11, 2011 at 9:20
  • Of course. But both the server and the client are built-in in Windows and Linux, so this is by far the easiest solution.
    – Massimo
    Oct 11, 2011 at 10:04
  • 2
    I agree, but I felt the warning is necessary nevertheless (and the downvote isn't mine :) ).
    – Sven
    Oct 11, 2011 at 10:33
  • 1
    Can't you see the downvoter's identities above 20k of reputation and start a crusade of wrath and revenge? If not, it surely is worth a feature request.
    – the-wabbit
    Oct 11, 2011 at 11:35
  • 1
    @Massimo - simply claiming otherwise would prevent unnecessary downvotes with the least harm done.
    – the-wabbit
    Oct 11, 2011 at 12:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .