Regularly backing up your Power Platform environments ensures data protection, disaster recovery, and compliance. Using PowerShell, you can:
✔ Schedule automatic backups for environments
✔ Retrieve existing backups for restoration
✔ Automate backup management via Task Scheduler or CI/CD
Step 1: Prerequisites
1.1 Install Power Platform PowerShell Modules
Ensure the required PowerShell modules are installed:
Install-Module -Name Microsoft.PowerApps.Administration.PowerShell -Force
Install-Module -Name Microsoft.PowerApps.PowerShell -Force
1.2 Authenticate to Power Platform
Log in to your Power Platform admin account:
Add-PowerAppsAccount
1.3 Identify Available Environments
List your environments and note the Environment Name:
Get-AdminPowerAppEnvironment | Select-Object DisplayName, EnvironmentName
Output Example:
DisplayName EnvironmentName
------------ -----------------------------
ProductionEnv 12345678-90ab-cdef-1234-567890abcdef
DevelopmentEnv abcdef12-3456-7890-abcd-ef1234567890
Step 2: Creating an Automated Backup
2.1 Create a Manual Backup
Use this command to trigger an on-demand backup:
$environmentName = "12345678-90ab-cdef-1234-567890abcdef"
New-AdminPowerAppEnvironmentBackup -EnvironmentName $environmentName
This creates a backup for the specified environment.
2.2 Verify Backup Creation
Run the following to list existing backups:
Get-AdminPowerAppEnvironmentBackup -EnvironmentName $environmentName | Select-Object Name, CreatedTime, State
Sample Output:
Name CreatedTime State
------------ ------------------- -------
Backup-Prod-001 2025-03-24 10:00:00 Completed
Step 3: Automating Backups via PowerShell Script
3.1 Create Backup Script (Backup-PowerPlatform.ps1)
param (
[string]$environmentName = "12345678-90ab-cdef-1234-567890abcdef"
)
# Authenticate
Add-PowerAppsAccount
# Create Backup
New-AdminPowerAppEnvironmentBackup -EnvironmentName $environmentName
# Log Backup Activity
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
$logFile = "C:\PowerPlatform\BackupLog.csv"
$logEntry = "$timestamp,$environmentName,Backup Created"
Add-Content -Path $logFile -Value $logEntry
Write-Host "Backup for $environmentName completed and logged."
This script automatically backs up an environment and logs the activity.
Step 4: Scheduling the Backup Task
4.1 Open Task Scheduler
- Press Win + R, type
taskschd.msc
, and hit Enter. - Click Create Basic Task → Name it Power Platform Backup.
- Choose Daily or Weekly.
- Set the time for automatic execution.
- Select Start a Program and enter:
powershell.exe -File "C:\Scripts\Backup-PowerPlatform.ps1"
- Click Finish.
Now, backups will run automatically based on the schedule.
Step 5: Automating Backups in Azure DevOps
To integrate backups into CI/CD Pipelines, use the following PowerShell task:
- task: PowerShell@2
inputs:
filePath: 'Backup-PowerPlatform.ps1'
arguments: '-environmentName "12345678-90ab-cdef-1234-567890abcdef"'
This ensures automatic backups before deployments.