Day 24: User defined backup scripts in Lights-Out 2
This blog post closes the backup topic of our step-by-step series. Today we look at user defined backup scripts in Lights-Out 2.0. User defined means, that you can run a command or backup program in a batch file like, for example robocopy.
Caveat emptor
Double check what you are doing. Verify that these files are not writeable for everybody!
Please be aware, that Lights-Out tracks the executing of the user defined backup scripts file. As along as the batch file is executed, Lights-Out blocks any standby. This requires that commands are executed synchronously. If you run an asynchronous command that triggers a background job and then exits, Lights-Out can not detect that background activity.
Also keep in mind, that SYSTEM can not directly access network shares, it’s identified as anonymous. If your work in a domain environment, then read this answer on serverfault.
User defined backup scripts on the server
This is the simple case. Navigate to “C:\Program Files\AxoNet Software GmbH\LightsOut2\backup”. There is a template file called server_backup.txt. Rename the file to server_backup.cmd and append your backup commands.
Result Mapping
Exit codes are mapped to backup results:
0 = success
1 = failed
2 = aborted
3 = warnings
4 = undefined
Sample server_backup.cmd
@echo off rem ************************************************************************ rem User defined server backup rem rem Rename this file to server_backup.cmd and add your backup commands here. rem rem Note: This file is executed under SYSTEM account. Verify that it's rem NOT WRITABLE for anybody else. rem ************************************************************************ xcopy "D:\ServerFolders\*" g:\usb_backup /k /r /e /i /s /c /h /y
Then run the server backup manually or add a schedule as always. Verify that the batch commands do not need interactive user input! Otherwise the execution will block.
User defined backup scripts on the client
Navigate to “C:\Program Files\AxoNet Software GmbH\LightsOut2Client\backup”. There is a template file called client_backup.txt. Rename the file to client_backup.cmd and append your backup commands.
The key difference here is, that you can call the Lights-Out client command line to indicate that you are doing backups and to report backup progress.
These three parameters are used with backup:
-r | –report_backup_started | Report that a user defined backup has started |
-f r | –report_backup_finished r | Report that a user defined backup has finished, Result r = 0 = success, 1 = failed, 2 = aborted, 3 = warnings, 4 = missed, 5 = wrong config, 255 = unknown |
-p n | –report_backup_progress n | Report backup progress in percent, range n = 0 – 100 |
Sample client_backup.cmd
@echo off rem ************************************************************************ rem User defined client backup rem rem Rename this file to client_backup.cmd and add your backup commands here. rem rem Note: This file is executed under SYSTEM account. Verify that it's rem not writeable for anybody else. rem ************************************************************************ rem signal backup is running "C:\Program Files\AxoNet Software GmbH\LightsOut2Client\LightsOut2.Client.Commandline.exe" -r rem put your backup command(s) here xcopy ... rem signal backup is half finished "C:\Program Files\AxoNet Software GmbH\LightsOut2Client\LightsOut2.Client.Commandline.exe" -p 50 xcopy ... "C:\Program Files\AxoNet Software GmbH\LightsOut2Client\LightsOut2.Client.Commandline.exe" -f %ERRORLEVEL%
Again, run the client backup manually or add a schedule as always.
Summary
User defined backup scripts are a compromise solution if your backup solution is not directly supported in Lights-Out or if you have the need to run special hand crafted batch files.
This was the closing post on the backup topic. Tomorrow we will look at an experimental feature to run user and system scripts.
Here you will find the complete list of all days of our step-by-step series.