Skip to content

Performs a backup of a directory and moves it to a specified folder

License

Notifications You must be signed in to change notification settings

begroff/Backup-Application

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Backup Application

Summary

Performs a backup of a directory containing application files by creating a zip archive appended with the current date and time, and moving it to a specified backup directory location. Checks the specified backup directory location and only keeps the latest 2 files older than 2 weeks.

Requirements

  • Powershell, Version 5.1.14409.1018 or higher
  • Pester, Version 4.9.0 or higher (to run unit tests)
  • Windows 10 / Windows Server 2012 or higher

Notes

This script can be run in three different ways:

Provide the arguments exclusively

.\Backup-Application -sourceDirectoryPath "D:\WwwRoot\ApplicationName" -backupDirectoryPath "D:\Backups" -applicationName "ApplicationName"

Provide the arguments in the correct order

.\Backup-Application "D:\WwwRoot\ApplicationName" "D:\Backups" "ApplicationName"

Provide the script name, press Enter, and input the required arguments at the command prompt.

.\Backup-Application
sourceDirectoryPath:

Usage/Examples

Backup a directory that contains no spaces

PS > .\Backup-Application -sourceDirectoryPath "D:\WwwRoot\MyAwesomeApplication" -backupDirectoryPath "D:\Temp\Backups" -applicationName "MyAwesomeApplication"

Backup a directory that contains spaces

PS > .\Backup-Application -sourceDirectoryPath "D:\WwwRoot\My Awesome Application" -backupDirectoryPath "D:\Temp\Backups" -applicationName "My Awesome Application"

Unit Tests

There are tests created with Pester than can be run to verify the script functionality. The tests are configured to run with Pester version 4.9.0. To check your Pester version, run the following command in PowerShell

Get-Module -Name "Pester"

If you are running a lower version, follow the installation steps here https://pester.dev/docs/introduction/installation

To run the tests, open PowerShell, navigate to the project root folder and run the following commands

cd Tests
.\Run-Tests.ps1

About

Performs a backup of a directory and moves it to a specified folder

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published