Compare Report after backup

I’m new to Duplicati but I’m enjoying it so far.

One thing I’d like to do though is have a log file generated after every backup with something along the lines of the compare command (on a Windows machine).

I’m guessing it would need to compare set 0 and 1 with the option of --full-result but I don’t know how to do it.

Is there anything built into Duplicati for this? I can see report options for mail, http and xmpp, but I just want a simple timestamped .log file with the result of the compare command.

Is this possible? I’ve looked at the script for after a backup, but would my .bat(?) file need to have all my unencrypted passwords in it or is there a better way?

Welcome to the forum!

You are right, you can use the COMPARE command to generate a list of all file differences between two backup snapshots.

I would use the --run-script-after option and point it to a batch file. The batch file does not need to contain your encryption passphrase or your credentials to the back end as the comparison is done using the local database only.

Here’s a Windows batch file that might help you get started:

if not "%DUPLICATI__OPERATIONNAME%" == "Backup" exit 0

pushd %~dp0
"C:\Program Files\Duplicati 2\Duplicati.CommandLine.exe" compare file://blah 1 --dbpath="%DUPLICATI__dbpath%" --full-result > "%DUPLICATI__backup_name%.log"
popd

You can leave the storage-url set to file://blah - it’s not actually used by the compare command, but it is still a required parameter.

It will save a backupname.log file in the same location as the batch file. You could add a timestamp to the log filename without too much trouble if you wanted to keep each log instead of overwriting each time. (But you’d want to clean them out regularly so they don’t build up…)

It won’t email the log though. I don’t think there’s a way to have Duplicati include file attachments in its email notifications.

I’m using the special duplicati environment variables to avoid hard coding any info into the script. If you have multiple jobs you could use this one script in the global --run-script-before option instead of setting it on each individual job.

I haven’t actually tested the above script but I think it’ll work. It’s a starting point at least.

Brilliant thanks! That’s really helped me out!

Now that you got a report, you could experiment to see if Duplicati can send it with send-mail-body where the run-script-after builds the compare report and feeds it in as a template (and I hope things run in that order…).

Beware of filenames that happen to look like things-between-percent-signs that would be substituted away…

I don’t think COMPARE works the way it’s implied in this thread. I tried the command at a terminal prompt and

  1. I got prompted for the encryption phrase
  2. It complained because “blah” does not exist

And no comparison file was generated

Did you supply it on the command line in the --passphrase option? Options are not automatically obtained from any GUI job you might have. You need to supply all the needed ones, typically a subset of all of them.

Frequently extras don’t hurt, so you can Export As Command-line from the GUI for a starter line to modify.

GUI Commandline also carries in all the options, so you can just change “Command” and remove proven-harmful mismatches with syntax for The COMPARE command. I cut mine down to what was suggested, adding only --passphrase, and it worked. I even tested with and without a 1 on the line that might be extra.

I can get this if I don’t supply the --dbpath (a user error). Listing remote folder tries but it’s not there.

I’m guessing all those things are in environment variables for a run-after script…?

Seems likely. Documentation is in your Duplicati installation folder, with seemingly most relevant piece:

I ran a little run-script-after to dump variables to a file, and got them. Backup isn’t encrypted, so I got this:

DUPLICATI__no_encryption=true
...
DUPLICATI__passphrase=

YMMV

Yes - did that, got a readout of all the “stuff” the after-script has to use. Very interesting. Thanks.

2 Likes