This PowerShell script automates the process of backing up important files from a specified source directory to a target backup directory. Scheduling regular backups is essential for data security and integrity, especially for businesses relying on software solutions like ServerEngine. By using this script, users can ensure their critical data remains safe and can be easily restored in case of accidental loss or corruption.
powershell
param (
[string]$sourceDirectory = "C:\ImportantFiles",
[string]$backupDirectory = "D:\Backups",
[string]$dateStamp = (Get-Date -Format "yyyy-MM-dd")
)
# Create a new backup folder with today's date
$backupPath = Join-Path -Path $backupDirectory -ChildPath $dateStamp
New-Item -ItemType Directory -Path $backupPath -Force
# Copy files to the backup directory
Copy-Item -Path $sourceDirectory\* -Destination $backupPath -Recurse -Force
Write-Output "Backup completed successfully. Files from $sourceDirectory have been backed up to $backupPath."Run it across your fleet
This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.
Ready when you are.
Try ServerEngine free for 7 days.