locked
Can Backups be scripted? RRS feed

  • Question

  • In the WHS console on the Computers & Backup tab there is a Backup Now button to initiate a backup of a client PC. I've noticed that this control will work regardless of whether the client PC has the WHS Tray App running or not. How does this work? I thought that the automatic nightly backups were initiated from a scheduled task running on the client PC, or manually by executing BackupNow.exe on the client, so how does the server initiate a backup?

    Fortuitously, server-side control of the backup process is exactly what I'm looking for. I need a way to make automated backups work with PCs that do not support S3 standby state. I know that a backup can be initiated on the client by running "C:\Program Files\Windows Home Server\BackupEngine.exe -a". But is there a way to initiate the Backup Now function from a script running on the server that does the same function as pressing the button in the WHS console GUI?
    Sunday, July 26, 2009 2:19 AM

Answers

  • To close out this thread, I have succeeded in getting server-side backups to work. The successful script is resident on and runs on the server, and is started from a scheduled task. The script then does the following:

    1. Wakes the PC using wake-on-lan (wolcmd.exe from www.depicus.com)
    2. Waits for confirmation that the PC is awake
    3. Waits another minute for the startup tasks to finish and the PC to become idle
    4. Starts the backup using Mark Russinovitch's PsExec.exe command (from Microsoft) to remotely execute C:\Program Files\Windows Home Server\BackupEngine.exe -a on the target PC
    5. Waits for confirmation that the backup has completed
    6. Turns off the target PC using shutdown -m MachineName -s -f -t 30

    This does what I need to automate backups of PCs with inadequate power management capability.

    Ken, thanks for the pointers.



    • Marked as answer by Mark Wharton Monday, July 27, 2009 1:01 AM
    Monday, July 27, 2009 1:01 AM

All replies

  • No, backups can't be scripted server-side, or at least there is no supported way to do so. It might be possible to hook into the backup engine using undocumented APIs. For that you'll need a tool such as .Net Reflector to find the APIs you need. And you'll need to bear in mind that the API may change in future versions of the product, so your scheduling tools may break.

    Backups on the client aren't initiated from a scheduled task, BTW, they're run off a hardware timer, which is how a PC wakes for backup if in hibernation/sleep mode.
    I'm not on the WHS team, I just post a lot. :)
    Sunday, July 26, 2009 3:19 AM
    Moderator
  • Ken:

    I was afraid of that. But tell me, do you know how the server is able to initiate a manual backup on a client? In other words, I can have a client PC on the network that is on (or was just turned on remotely by WOL) but does not have the WHS Tray App running. From another machine I can RD to the server and start the WHS console on the server, and initiate a manual backup of the client. Does the server then tell the client to run BackupNow.exe , and if so, how is this communicated to the client?

    It seems that all of the pieces to do what I need are in place except that the backup has to be started from the GUI instead of from a command prompt. Perhaps a better approach for me is to write a backup script that resides on the client PC and then figure out how to trigger the script remotely from the server.
    Sunday, July 26, 2009 1:03 PM
  • The server and client are in constant communication. Once the client has notified the server that it's awake and online, that communication can include the server saying to the client "a backup has been requested, so start one now" and the client will do so.

    The tray app is just a convenient way for a user to interact with the client tools; if it's not running the client is (as you've seen) still fully connected to the server when running. The component that handles the actual communication is the Windows Home Server Connector Service . One other thing that you seem not to be aware of: the Windows Home Server console is an application that runs on the server, even when started on a client. On a client it's remoted to that computer using a Remote Desktop session from which most chrome has been removed. So whether you start the console from a client or a Remote Desktop session with your server, it's still running on the server and communicating with the client in the same way.

    When you contemplate all of this, you should bear in mind that Windows Home Server is designed to be a product for use in the home, by persons without significant technical knowledge or skill. In order for Microsoft to add flexibility to Windows Home Server (in any area, not just the backup engine) to support business use or better management as seen by the eyes of an IT professional, they would have to introduce additional complexity that would (not might, would ) confuse the primary target audience. One of the design philosophies for the team is to make the "right decision" for the target market whenever possible, so as to avoid unnecessary knobs and buttons. In this case, that "right decision" is a backup that runs automatically for all PCs (unless turned off) during a window that is set for the entire home.

    My recommendation is to set the backup window, establish a "best practice" that users will use some combination of manual or automatic standby/hibernation on desktop computers, and let the Windows Home Server backup engine function as designed.

    I'm not on the WHS team, I just post a lot. :)
    Sunday, July 26, 2009 2:32 PM
    Moderator
  • Thank you for the additional clarification, but there is something that the design team overlooked or chose to ignore, and that is older PCs that do not support S3 standby. If you have one or more of these machines on your network then the automatic backup solution will not work very well for them. And there are also user habits to contend with. I have the worst-case situation of having a family member who insists on always shutting down their PC when finished with it, even after being shown how to hibernate it. And, this PC does not support S3 so if the automatic backup solution is enabled for this PC, even if initially hibernated, the PC is put into standby when the backup finishes. This is undesirable because this PC's supported standby method, S1, runs the fans continually and does not save very much energy in this mode, plus it makes unnecessary noise. For the oddball situation like this it is necessary to either back the machine up manually or else look for alternate methods for accomplishing automated daily backups.

    While I understand the UI complexity argument, if the WHS designers had left a few command-line functions for advanced users then that would have been ideal. The primary target audience could be blissfully unaware of their existence yet they would be available for advanced users who need to do something out of the ordinary to overcome a problem not covered by the automated backup function.

    The automated backup works very well with my Vista desktop PC, which I am in the habit of always leaving in Hybrid Sleep mode. But it is unsatisfactory on the aforementioned older PC, so if I want it to be backed up automatically then I must figure out a way to script it. Currently I have everything else scripted and working -- waking the PC up remotely from the server and shutting it off when finished -- so all that remains is to figure out how to trigger a backup. I'll get there somehow, but it would be nice if future versions of WHS could include a few command-line functions for this purpose.
    Sunday, July 26, 2009 5:10 PM
  • To close out this thread, I have succeeded in getting server-side backups to work. The successful script is resident on and runs on the server, and is started from a scheduled task. The script then does the following:

    1. Wakes the PC using wake-on-lan (wolcmd.exe from www.depicus.com)
    2. Waits for confirmation that the PC is awake
    3. Waits another minute for the startup tasks to finish and the PC to become idle
    4. Starts the backup using Mark Russinovitch's PsExec.exe command (from Microsoft) to remotely execute C:\Program Files\Windows Home Server\BackupEngine.exe -a on the target PC
    5. Waits for confirmation that the backup has completed
    6. Turns off the target PC using shutdown -m MachineName -s -f -t 30

    This does what I need to automate backups of PCs with inadequate power management capability.

    Ken, thanks for the pointers.



    • Marked as answer by Mark Wharton Monday, July 27, 2009 1:01 AM
    Monday, July 27, 2009 1:01 AM