I have been using Duplicati for years and really like it. I have Duplicati 2.2.0.3 on Windows 11. To apply the 3-2-1 rule, I would like to chain my backups, which are stored in three different locations. I discovered run-script-after and I assume that should allow me to do this. But I am unable to write a command line that works. I tried to understand the documentation, but, as they say in French, “it goes over my head.” Especially the variables. Is this feasible? Thank you in advance for any help.
I have something similar where each server has 3 backups, the first backs up locally, it then spawns the second which goes to Wasabi S3, and finally a small job to back up the databases of the other two jobs because I’m paranoid.
Only the first job is scheduled, and then it runs this after in order to run the next job (one script that runs the job depending on which job runs the script, hope that makes sense)![]()
@echo off
for /f "tokens=*" %%a in ('powershell -noprofile -command get-date -format "yyyyMMdd_HHmm"') do set datetime=%%a
set logfile=%~dp0
set logfile=%logfile%Logs\duplicati_after_%DUPLICATI__BACKUP_NAME%_%datetime%.log
echo Duplicati After script for %DUPLICATI__BACKUP_NAME% started>%logfile%
echo ===== Environment>>%logfile%
set>>%logfile%
echo ===== Environment>>%logfile%
for /f %%a in ('powershell "&{(Get-Date).DayOfWeek}"') do set wd_=%%a
echo Today is %wd_%>>%logfile%
for /f %%a in ('powershell "&{[int](Get-Date).Hour}"') do set wt_=%%a
echo Hour is %wt_%>>%logfile%
if /i not "%DUPLICATI__OPERATIONNAME%"=="Backup" (
echo Not a backup, aborting [%DUPLICATI__OPERATIONNAME%]>>%logfile%
goto end
)
if /i not "%DUPLICATI__PARSED_RESULT%"=="Success" (
if /i not "%DUPLICATI__PARSED_RESULT%"=="Warning" (
echo Job error, aborting [%DUPLICATI__PARSED_RESULT%]>>%logfile%
goto end
)
)
if /i "%DUPLICATI__BACKUP_NAME%"=="LISA-Local_Backup" (
echo Running Duplicati Wasabi backup>>%logfile%
start "" "C:\ProgramData\Duplicati\Run-Backup-LISA_WASABI.cmd"
)
if /i "%DUPLICATI__BACKUP_NAME%"=="LISA-Wasabi_Backup" (
echo Running Duplicati config backup>>%logfile%
start "" "C:\ProgramData\Duplicati\Run-Backup-LISA_DP.cmd"
)
:end
echo Duplicati After script for %DUPLICATI__BACKUP_NAME% ended>>%logfile%
An example of the next job is:
@echo off
for /f "tokens=*" %%a in ('powershell -noprofile -command get-date -format "yyyyMMdd_HHmm"') do set datetime=%%a
set logfile=%~dp0
set logfile=%logfile%Logs\duplicati_LISA_WASABI_%datetime%.log
if /i not "%DUPLICATI__OPERATIONNAME%"=="BACKUP" exit 0
"C:\Program Files\Duplicati 2\Duplicati.CommandLine.ServerUtil.exe" --server-datafolder C:\ProgramData\Duplicati --hosturl https://lisa.mydomain:8200 run 1 >>%logfile% 2>&1
exit
One of the key things which I find annoying is that any function run on a backup job will call its main after script, so it must check if it’s actually doing a backup and not a repair/restore/prune etc with something like:
if /i not "%DUPLICATI__OPERATIONNAME%"=="BACKUP" exit 0
Problem solved! It works perfectly now. Thanks for your help.
Keep a lookout for the next canary build as we will be adding the option to choose multiple destinations for the backup data, so you can get 3-2-1 without resorting to multiple backups or custom scripts ![]()
That sounds great, but will it handle backups that already exist at the destination? I can’t afford to restart some of my backups, so some kind of import of the pre-existing data will need to happen.
For me, it didn’t damage anything in my backups. Neither the database nor the connections. I tried many different things before finding this solution. My .bat files triggered a lot of errors, but I never had to redo the backups.