46690: Acronis Backup: Troubleshooting Pre/Post Commands Issues

    Last update: Wed, 2020-07-08 12:21

    About

    Pre-/Post-Backup or Pre/Post data capture commands can be used for various operations such as:

    • Stopping services of non-VSS-aware application before snapshot and starting them after backup;
    • Running troubleshooting scripts on automated basis if a problem is not stably reproduced.

    See more in following articles:
    Acronis Cyber Backup 12.5 Web Help: Pre/Post commands
    Acronis Cyber Backup 12.5 Web Help: Pre/Post commands
    Acronis Backup 11.7 Web Help: Pre/Post commands
    Acronis Backup 11.7 Web Help: Pre/Post data capture commands

    Pre/Post commands are executed by Acronis agents both in local and centralized backup plans.

    Troubleshooting

    Follow step-by-step instructions below to troubleshoot the issue. Complete prerequisites step before proceeding to error troubleshooting step.

    1. Prerequisites

    Check the following steps before proceeding to error troubleshooting step.

    1.1 Correct syntax

    Make sure that your script exists and is working without Acronis: run it explicitly (in CMD, PowerShell, or bash shell), and check the results (see more to it in the Troubleshooting part, if it does not work). Take a screenshot of it.

    1.2 Correct backup plan settings

    Example on the screenshot below shows the use of arguments:

    1. In the Command field, type a command or browse to the batch file. The program does not support interactive commands, i.e. commands that require user input (for example, "pause")
    2. In the Working directory field, specify a path to a directory where the command/batch file will be executed. This is a directory context of the command. This is not the folder with the batch file. This is equivalent to issuing command "cd FOLDERNAME" before running actual script.

    3. In the Arguments field specify the command’s execution arguments, if required.

    If all steps above have been executed and issue still persists, go to error troubleshooting step.

    2. Error troubleshooting

    Complete all steps before proceeding to collect information step.

    2.1 Script is accessible

    Make sure the destination of your script is accessible by Acronis software:

    • When using Centralized management in Acronis Backup, place the script either on a share or on each agent. E.g. if you put "C:\somefile.bat" then each agent has to have "C:\somefile.bat".
    • If the script is on a network share make sure that the user that is running the backup plan has access to this share. Try to open the share in Windows Explorer providing credentials specified in the backup plan.

    As the Agent is the component that is performing backup, it is also running pre/post commands, when fulfilling the conditions of a backup plan. If the pre/post command is valid for every agent in the backup plan, make sure that the script is placed on a file share accessible from every agent (try to open the share in Windows Explorer providing credentials specified in the backup plan) or in the exact same local folder on every agent machine.  E.g. if you use "C:\somefile.bat" then each agent has to have "C:\somefile.bat".
    If you are backing up virtual machines using an Agent for Hyper-V, either place a script on the Hyper-V server or install Agents inside each VM, if you want something particular to be done with a VM.

    See also How to run script inside virtual machine during agentless backup

    2.2 Script is working

    Make sure your script actually succeeds.To succeed your script has to return “0”.

    To check the exit code you should:

    - In Windows: open Command Prompt (start -> run -> cmd). Execute your script in the CMD. Then issue command "echo %errorlevel%". This will output the exit code.
    If script succeeded, you will see:

    - In Linux: execute your script in the bash shell. Then issue command "echo $?". This will output the exit code.

    If your script does not return 0 but you want to force it you can use exit /B 0" in batch files in Windows and "exit 0" in bash in Linux.

    2.3 Debug file

    In case your script works without Acronis but fails when run by Acronis you should add some debug file outputs to make sure what is wrong. In batch files that is easily done by adding this line into your batch file: 

    echo "Debug Info" >> C:\temp\debuglog.txt

    Expected result of this debug procedure is to check whether the script is successfully executed until it reaches this command. In this case a file with "Debug Info" is created in C:\temp.debuglog.txt You can localize the faulty command by inserting this line after the part you want to check in your script or by giving it another parameters.

    What and where to put the debug outputs and the content of those outputs depends on the running script itself. Adjust this method depending on your script.

    If all steps above have been executed and the issue still persists, go to collect information step.

    3. Collect information

    Collect following information and contact Acronis Customer Central.

    3.1 Backup plan 

    Export of the backup plan.

    • To export the backup plan in Acronis Backup 12.5 and later, navigate to Plans view, select the plan you are having problems with, click Export button in the menu on the right and save the plan as JSON file.
    • Acronis Backup 11.5/11.7: see: Acronis Backup: Import and Export of Backup Plans

    Or make screenshots of the backup settings.

    3.2 Script

    The script that you are trying to run as Pre/Post command (as a txt file or as a screenshot)

    3.3 Process Monitor log

    Reproduce the problem and collect Process Monitor log on the Agent machine during script execution.

    3.4 Log

    Log of failing backup plan:

    • Acronis Backup 12.5 : copy the entire text of error for the failing activity (open its Details) or export the log of error
    • Acronis Backup 11.5/11.7: right-click on the plan -> Log -> Save to file.

    If Centralized Backup plan is used System Report from Acronis Management Server is also required.

    3.5 System Report

    Collect System Report from the machine in question. If Centralized Backup plan is used System Report from Acronis Management Server is also required.

    If this fails for any reason, you can use this AcronisInfo Utility.

    Tags: