Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

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

share|improve this answer

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

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

share|improve this answer
4  
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
2  
I 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
1  
@Massimo - simply claiming otherwise would prevent unnecessary downvotes with the least harm done. –  the-wabbit Oct 11 '11 at 12:30

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

Your Answer

 
discard

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.