All those who work closely with PowerShell will be interested in this capability in DocAve 6 – this regards how you can respond with PowerShell with the new DocAve 6 API. The DocAve 6 PowerShell API is provided with the opportunity to address backup, and we will be releasing support for additional modules in subsequent service packs.
For the purpose of this blog article, I want to portray a simple, yet realistic scenario you can deploy today:
Short Description: Using PowerShell script in SharePoint creates a subsite, which contains a document library. In this document library, a dummy document is loaded. This subsite is then secured with DocAve’s Granular Backup. The plan and its configuration is created with PowerShell, and after the plan is passed onto DocAve, it will start using PowerShell. The result of the backup is also checked with PowerShell and listed.
Procedure:
After installing DocAve 6, you will see a menu item called “DocAve 6 Management Shell”.
This link runs a shell window. The SharePoint extension is not loaded automatically, however: This was not meant to catch up with a simple command.
Add-PSSnapin Microsoft.SharePoint.PowerShell
Step 1 – Login
To work with the DocAve API, it is necessary to connect to the DocAve Control Service. This is to ensure that no unauthorized person, or process, can send to DocAve.
There are three ways to login:
1. Interactive via a login screen:
Step 2 – The Plan
DocAve has a backup plan object, which can be created as well. It can either be an existing plan or a blank plan template.
Existing Plan:
$backupPlan = Get-DocAveGranularBackupBlankPlan
Blank Plan Template:
$backupPlan = Get-DocAveGranularBackupPlan -Name "Backup Plan by PowerShell"
Now, it’s possible to change the attributes of the backup plan or set.
Please Note: It is extremely important at this point that all attributes are set before you add onto the Tree.IncludeSPObject
The set of attributes works very simply, via direct access to the attribute name.
$BackupPlan.Name = "backup plan by PowerShell" $BackupPlan.Description = "this backup plan has been created by powershell"
$BackupPlan.StoragePolicyName = "Backup to Cloud" $BackupPlan.AgentGroupName = "AllAgents"
The bits are the way to restore levels as follows:
Item Level 1 = 2 = Site Level 4 = Site Collection level
The plan now must describe what to include in the backup. This requires the production of a SPObject, which can be:
· SPList list = Library
· SPSite site = collection
· SPWeb site = sub
· SPWebApplication = Web Application
An example to secure a site collection is as follows:
Now, what parameters must be used in order to find the API documentation in the installation directory of DocAve?
Having defined what should be preserved, we need to pass the object to the plan.
$backupPlan.Tree.IncludeSPObject($sourceObject)
Here, you can easily add additional sources by renewed calls to the appropriate object.
The configuration of the plan you can control can be displayed again, as below:
Step 3 – Now it’s getting serious
The backup plan or Plan object must now be transferred into DocAve. Here, I’d like to make it clear that a “plan” is still not the same as a “task”.
The transfer of the plan object in DocAve using PowerShell is below:
New-DocAveGranularBackupPlan -Plan $backupPlan
In DocAve 6, it looks like this:
If you have loaded an existing plan from the plan in the DocAve object, you can perform an update of the existing plan in DocAve using Update:
Update-DocAveGranularBackupPlan -Plan $backupPlan
Step 4 – Showtime
Now, it’s time for the backup plan to start in DocAve via PowerShell.
To let a job object in DocAve return, we can run a command to continue using the ID later.
$job = Run-DocAveGranularBackupJob -PlanName "backup plan by PowerShell" -BackupJobType full -JobReportType detailed
Alternatively, the job can be started so that you get in the console an ASCII Progress.
Run-DocAveGranularBackupJob -PlanName $newPlan.Name -BackupJobType full -JobReportType detailed -WaitForJobComplete
To bring the job status to experience, this code provides us with the DocAve status:
Get-DocAveJob -ID $job.ID
Step 5 – What is happening?
If our backup is finished, we can check the status.
Get-DocAveJobSummary -ID $job.ID
The detailed report can also be downloaded as a CSV or XLS.
Download-DocAveJobReport -ID $job.ID -Format XLS -Path c:report.zipStep 6 – Removal
In the event that the backup job would be removed from DocAve, it also offers a DocAve commandlet.
Remove-DocAveGranularBackupPlan -Name "backup plan by PowerShell"
In Conclusion:
Working with the DocAve 6 PowerShell API is fun, and I’m looking forward to the next service pack, which will probably offer APIs for administration interfaces, content management, and BLOB retrieval.
Please create a dummy document and put themselves in the same directory as the script. Thanks to Thorsten Hans for his tips on creating a subsite with PowerShell.
PowerShell Script Download
Michael Denzler ist bei CGI Germany als Management Consultant tätig und ist von Microsoft zertifiziert als Technology Specialist (MCTS) und Professional Developer (MCPD). Er hat langjährige Erfahrung in der Unterstützung von Kunden bei der Umsetzung kostengünstiger und erfolgreicher Management-, Backup- und Optimierungs-Lösungen für Microsoft SharePoint. Seine Schwerpunkte sind dabei Migration, Backup und Recovery, Replikation, Storage-Optimierung und Archivierung.