When Duplicati backups and restores Nextcloud files, we want to enable maintenance mode.

However by default, Duplicati runs scripts on every operation including when it lists the restore folders, which we don’t want.

The following scripts prevents Duplicati from running the script when it’s only listing the restore folders.

If we restore the files, Nextcloud won’t realize the files are there because it’s not updated in the database, so we have to trigger a scan.