How to identify the source of an error arising when an APBackup task is executed using an external archiver?

APBackup allows you to run backup tasks using both the built-in Zip64 archiver and the majority of external archivers. To configure an external archiver for use with APBackup, you need to create/edit an external archiver configuration file (*.EMC). The APBackup distribution package contains configuration files for the most popular tools: WinRar, WinZip, Arj, 7-Zip, etc. However, you can add a custom configuration file for any other archiver. The process is described in detail in the program documentation (where WinRar is used as an example).

When a task is executed using an external archiver, APBackup creates a command line to start it using the information from the corresponding configuration file, creates a process for executing this command line and waits for the process to end. In this case, an archiving task is considered completed if the return code of the created process is 0 and the program finds a newly-created volume after the external archiver has finished working. If the external archiver returns a code different from 0, it means that the task has been completed with an error. Unfortunately, APBackup cannot identify what’s causing the error, as it is related to a different process it has no access to. So what can you do to find the source of the problem?

Let’s take a look at an example using 7-zip and demonstrating how you can obtain more information about an error occurring during the work of an external archiver. This method can be used for any console archiver.

Let’s switch the standard screen output of the archiver to output into a log file for this task.
Below is the command line executed in our task for the external archiver:

"C:\Program files\7-zip\7z.EXE" u -t7z -r -y "d:\testRS2\SS101216.7z" @"d:\testRS2\SS101216.IFM" -mx=5

To switch the output of the archiver to a text file, you need to add the following to the end of the line:

"C:\Program files\7-zip\7z.EXE" u -t7z -r -y "d:\testRS2\SS101216.7z" @"d:\testRS2\SS101216.IFM" -mx=5 > "d:\testRS2\SS101216.7z.7zlog"

In this case, all messages generated by the archiver will be saved to “d:\testRS2\SS101216.7z.7zlog”. The file has the name of the archive being created. That is, when the external archiver finishes the task, there will be a log file next to it containing any console messages it generated during its work, so you will be able to check what the problem was, if any.

Let’s make it work with APBackup now.

To start off, let’s create a .bat file that we will call instead of 7z.exe. This file, in turn, will call 7zip and pass over the parameters that were first passed to the .bat file itself.

"c:\Program files\7-zip\7z.exe" %*

Now, let’s create a new configuration file in APBackup based on the file for 7-ZIP (7-Zip.EMC). Use the “Preferences – Edit Configurations of External Archivers”. Let’s open 7-Zip.EMC and save it under a new name – like 7ZipWLog.EMC, for instance.

All we need to do now is to change the command line and the parameters line. Let’s add the path to the previously created 7Zip.bat file to the command line and add the following to the end of the parameters line:

> "[ArchiveName].7zlog"

In this case, when a task is executed, the [ArchiveName] macros will be replaced with the name of the archive being created.

Once the configuration file has been saved, you need to restart APBackup to enable it to add the new file to the list of external archivers.

From now on, you will be able to select an external archiver called 7ZipWLog for any task. It will create a log with the name of the created archive and will have the “7zlog” extension.

This method can be used for any archiver supporting the console mode.

Related links

Using external archivers in APBackup
Configuring external archivers in APBackup