Disclaimer: This was created as part of a learning exercise, as a source to use PowerShell. Yes, Robocopy exist and can do a much better job than this alternative. Again, it's just an exercise.
This PowerShell script performs incremental backups of specified source folders to a destination path. It tracks changes using a manifest file and logs all operations for debugging and auditing purposes.
- Incremental backup: Only copies files that are new or modified.
- Handles long file paths by using the
\\?\prefix. - Deletes old backups older than 7 days to save space.
- Logs all actions to a log file for traceability.
- PowerShell 5.1 or later.
- Administrative privileges (if accessing certain directories).
- Replace the placeholders in the script:
$sourceFolders = @("<!-- Insert source folders here -->") $destinationBase = "<!-- Insert destination path here -->"
$sourceFolders = @("C:\Users\USER1\Desktop", "D:", "F:") $destinationBase = "Z:\Backups"
- .\IncrementalBackup.ps1
- Modify the $cutoffDate variable to change the retention period for old backups.
- Adjust logging behavior by editing the $logFile section.