question

DnyaneshwarSurywanshi-3200 avatar image
0 Votes"
DnyaneshwarSurywanshi-3200 asked PaulFinol commented

how to full backup of Virtual Machine using MARS agent with PowerShell ?

I want to backup my Virtual Machine using MARS agent. Below is my script for configuring backup schedule but I want full backup not drive folder level.

$BackupPolicy = New-OBPolicy

Create backup schedule (modify variables as required)

$DaysOfTheWeek = "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
$TimesOfDay = "23:30"
$BackupSchedule = New-OBSchedule -DaysOfWeek $DaysOfTheWeek -TimesOfDay $TimesOfDay

Associate schedule with the blank policy you created above

Set-OBSchedule -Policy $BackupPolicy -Schedule $BackupSchedule

Configure Backup Retention and associate with our policy (modify variables as required)

$RetentionDays = "30"
$BackupRetentionPolicy = New-OBRetentionPolicy -RetentionDays $RetentionDays
Set-OBRetentionPolicy -Policy $BackupPolicy -RetentionPolicy $BackupRetentionPolicy

Configure file and folder inclusion/exclusion policy (modify variables as required for your client machine/server)

$Inclusions = New-OBFileSpec -FileSpec @("C:\", "D:\")
$Exclusions = New-OBFileSpec -FileSpec @("C:\windows", "C:\temp") -Exclude
Add-OBFileSpec -Policy $BackupPolicy -FileSpec $Inclusions

Commit new policy for use by Azure Backup

Set-OBPolicy -Policy $BackupPolicy -Confirm:$false

azure-backup
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@DnyaneshwarSurywanshi-3200 - Thank you for contacting us.
Curious to understand your requirement for full backup of an Azure VM with MARS agent using PowerShell as there is already an Azure VM backup which can backup the entire VM as per the schedule you configure.
Reference: https://docs.microsoft.com/en-us/azure/backup/backup-architecture#architecture-built-in-azure-vm-backup

0 Votes 0 ·

@SadiqhAhmed-MSFT Thanks for the reply Currently in my project I am using ARM template with custom script extension to download the MARS agent and installed. Now I want to configure backup schedule and I am using above script for backup using MARS agent and try to backup C and D drive but is there any way to backup full VM using MARS agent with powershell. I want automation not manually below links currently i am using :

https://docs.microsoft.com/en-us/azure/backup/backup-client-automation

0 Votes 0 ·

1 Answer

SadiqhAhmed-MSFT avatar image
0 Votes"
SadiqhAhmed-MSFT answered PaulFinol commented

@DnyaneshwarSurywanshi-3200 Full Azure VM backup is better achieved using Azure VM backup rather than via MARS.

The closest option is to use system state backups along with File and folder backups. System state restore is a 2-stage process where MARS will pull down the backed up copy of the system state backup following which the user will need to use Windows Server Backup to restore the system state. The complexity on an Azure VM is that when the system boots into safe mode to restore the system state, RDP access is lost. Additionally if there were to be a problem with the System State restore, a Windows Recovery Environment may not be an option.

An alternative may be that you can choose to back up only the OS disk of the VM and use MARS for the rest of the data.


If the response helped, do "Accept Answer" and up-vote it


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

how to use wildcards in New-OBFileSpec command

these are the errors i get

Add-OBFileSpec: Cannot bind parameter 'FileSpec'. Cannot convert the "C:\dir1*.*" value of type "System.String" to type "Microsoft.Internal.CloudBackup.ObjectModel.OMCommon.CBFileSpec".

Set-OBPolicy: The specified file path C:\Users*.\Documents is invalid for one or more of the following reasons
1)File name cannot contain any of the following characters <>:"/\|?
2)File path cannot contain any of the following characters <>:"/\|
?
3)File path cannot be specified as a relative path. It cannot contain . and ..
4)File location cannot be specified using UNC path. If the file location path uses a relative path or a UNC path, change the file path to use an absolute path. If the file name of folder contains an unsupported character, you must rename the items before they can be backed up.

0 Votes 0 ·