Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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 '11 at 12:04

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.

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

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.

share|improve this answer

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.

share|improve this answer

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

share|improve this answer
Obligatory warning: Telnet is completely unencrypted, everything you type goes over the wire in clear text. – Sven Oct 11 '11 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 '11 at 10:04
I agree, but I felt the warning is necessary nevertheless (and the downvote isn't mine :) ). – Sven Oct 11 '11 at 10:33
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 '11 at 11:35
@Massimo - simply claiming otherwise would prevent unnecessary downvotes with the least harm done. – the-wabbit Oct 11 '11 at 12:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.