2 commands as script before


I’d like to set my Nextcloud into maintenance mode and dump the database before running the backup.

I tried 2 commands in the run-script-before line:
sudo -u www-data php /var/www/html/cloud/occ maintenance:mode --on && echo myPassword | sudo -u root mysqldump --single-transaction -h localhost -u nextcloud -pmyPassword nc > /media/2TBint/backup/nc/nextcloud-sqlbkp_'date +"%Y%m%d"'.sql

It does not work and I get no message in Duplicati log.

Alternatively I packed the commands in a shell script to run before backup. But this exits with code 255.

I can say that the script works. When I start it as cronjob all is fine.

What can I do to get it working just before the backup?


You should try putting this command into a bash script and run that from --run-script-before. It seems too difficult for Duplicati to handle this command and it’s parameters.