The scripts plugin allows the user to run custom commands as part of the backup process. Although Windows PowerShell is not currently supported in the scripts plugin, it is possible to use a PowerShell script to initiate a backup and to run commands both before and/or after the backup.
An example script is provided which makes it possible to automate different outcomes to the script depending on the success status of the backup. The default script also includes an example command for shutting down the machine. See the excerpt below:
if( $backupStatus = "Successful" )
{
# If Backup was successful, run this command. Leave empty to do nothing.
# Shutdown machine e.g.:
Stop-Computer
}
if( $backupStatus = "Successful with warnings" )
{
# If Backup was successful with warnings, run this command. Leave empty to do nothing.
}
if( $backupStatus = "Failed" )
{
# If Backup failed, run this command. Leave empty to do nothing.
}
Note:
- Backups will be shown as "Manual" rather than "Scheduled".
- You may need to change your script execution policy, e.g. Set-ExecutionPolicy Unrestricted.
- The script relies on the Windows Event Log.
To configure the script in the Task Scheduler:
- Create a folder to contain the scripts, for example a subdirectory in the installation directory (C:\Program Files\Attix5 Pro\Backup Client SE\scripts\).
- In the folder, create a file called "runbackup.bat", containing the following line:
powershell -ExecutionPolicy Unrestricted -File "C:\Program Files\Attix5 Pro\Backup Client SE\scripts\runbackup.ps1"
- In the same folder, save the PowerShell script file as "runbackup.ps1".
Note: If you do not want to shut the server down, ensure you remove the "Stop-Computer" example line from near the bottom of the file before running any scheduled tasks. - In Windows Task Scheduler, create a task with a trigger at your desired backup time.
- In the Actions tab, set the Action to "Start a program" and select the "runbackup1.bat" script. No arguments are required.
- Set the task to "Run whether a user is logged on or not" and enter an administrator username and password to save the task configuration.
Note: If you are running the scripts from a different location, you will need to change the file path where the scripts are located.
Comments
0 comments
Please sign in to leave a comment.