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.
-
`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
4 Answers
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.

- 40,737
- 13
- 111
- 174
-
-
Possible. We use a statically compiled version for several years now without running Samba4 - it works. – the-wabbit Oct 11 '11 at 09: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.

- 2,309
- 2
- 21
- 32
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.

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

- 70,200
- 57
- 200
- 323
-
4Obligatory warning: Telnet is completely unencrypted, everything you type goes over the wire in clear text. – Sven Oct 11 '11 at 09: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
-
2I agree, but I felt the warning is necessary nevertheless (and the downvote isn't mine :) ). – Sven Oct 11 '11 at 10:33
-
Ehy, if you don't like this answer, plase vote up another one. But you shouldn't downvote this one, as it's a perfectly working solution. – Massimo Oct 11 '11 at 11:18
-
1Can'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
-
-
echo SqlCmd -E -S MyServer –Q “RESTORE DATABASE [MyDB] FROM DISK=’D:sqlserverDB.bak’” | net rpc shell -I IPADDRESS -U USERNAME%PASSWORD Do you think this way I can execute the restore command on the remote windows server with net rpc? – BioLounge Oct 11 '11 at 11:50
-
No. The "net rpc shell" command is simply an "interactive shell for remote server/account management". It won't allow you running arbitrary commands. – the-wabbit Oct 11 '11 at 12:28
-
1@Massimo - simply claiming otherwise would prevent unnecessary downvotes with the least harm done. – the-wabbit Oct 11 '11 at 12:30
-