Automate Your Day – Make Your Own Online Backup Scripts
Posted by Steve Frank on Wed, Nov 30, 2011
My previous two posts dealt with tasks you could automate with the BackupCli and Management API. I think it is time to give you a chance to see what you can automate. To facilitate your script writing, I’ve put together a PowerGUI PowerPack with all sorts of goodies related to the Management API. Now many will say that they can do a lot of the tasks below using the Portal; well that may be correct, but with this you can see the xml commands we issue to make the magic happen!
Get it here: http://powergui.org/entry.jspa?externalID=3751&categoryID=52
Once you have installed it, you’ll need to configure it by clicking the “Configure” node and then clicking the “Configure…” action button. You’ll be prompted for your partner username and password. Additionally, you can enter in your REST API credentials if you have been provided them from support (after asking nicely of course). Though, the REST API credentials are not needed since you can simply use a csv file to tell the script which agents to contact, which we recommend until you have everything working correctly.
Let’s start out with, what is hands down, the most requested report: the backup set selection report. With the PowerPack installed, simply click the “Selection Audit” node and the code will contact each agent and get a list of what its backup sets are searching during each backup. And this isn’t just for file backup sets; it will even check Exchange and SQL. Curious how it works? Simply right-click the node, go to Properties, and view the shared script. You’ll see 1000’s of lines of code (I was bored one day…) so search for “BestPracticesSelectionAudit” and see how easy it to make.

I love these next two since they cover a topic that has always bothered me: am I fully protected? There are many items that need to be backed up on each server, and for those who have already setup a bunch you may not realize that on the 14th server you forgot to backup Exchange! So the first report will contact each agent, check to see which Exchange Info Stores are running, and then make sure there is a backup set for each one. How cool is that! (Just because a computer comes up as “UNSUPPORTED” doesn’t mean Exchange isn’t installed, so you should double check all of those manually.)

And then this report checks to make sure that every agent has a System State backup set created. And to prove how powerful the Management API is, you can select all the agents that have a missing backup set, then click “Create Backup Set” and the code will automatically create a System State backup set for you. (Though for now, it doesn’t create one with any schedules since this is for demonstration purposes only. So go make them manually through the Portal.)

Anyone who has used the Management Portal to configure an agent has seen the little “Connected” icon. This lets you know if you can actually administer that agent. Well wouldn’t you like to know all the agents that are disconnected, and fix them? Simply click the “Connection Status” report and it will find them all. Some common reasons an agent is disconnected are: it’s running Windows 2000, the computer is rebooting, the agent is outdated (e.g. 2.3.1), and the agent isn’t even installed (woops, I knew I forgot to do something!).

Every now and then you may want to send a report to a client showing them all the backups being performed. Well, you can do that! The example in the PowerPack is hardcoded to 30 days, but you can edit the code and change it to whatever you want. Once the report is done, you can use one of the custom actions in PowerGUI to export the list to Html, Csv or even to Xml!

And finally, the coolest feature of them all: programmatically restoring items. This will be the topic of my next post. I’ll show you how to restore a given file or folder at will. Every end-user has that one file, be it a customer database or a QuickBooks file, that rules their day-to-day activities, and without it, they are doomed. And if they are doomed, you are doomed. So you can run a script to make sure that every day the latest version of that file has been backed up, and optionally make sure that it is recoverable. Sounds pretty useful to me.

So what script or report will you make with this?
Got a question or suggestion about using the PowerPack? Email me at steve [at] intronis.com