0

I got the following script to run pre-backup stuff on my server :

#!/bin/bash
dump_name="nextcloud_$(date +%d-%m-%y_%H-%M-%S)_backup.sql"
printf "Enabling maintenance mode... " 
docker exec -u www-data nextcloud_front_1 sh -c "php occ maintenance:mode --on"
printf "\nDumping database...\n"
docker exec nextcloud_database_1 sh -c 'mysqldump -u root -p$MYSQL_ROOT_PASSWORD nextcloud' | sudo tee "/data/nextcloud/database/dumps/$dump_name" > /dev/null

This works normally when I run it on the server manually via SSH but I'd like to run it remotely :

ssh user@host 'bash -s' < script.sh

But then I get the following output among printf's:

" option does not exist.

maintenance:mode [--on] [--off]

Caused by this line

docker exec -u www-data nextcloud_front_1 sh -c "php occ maintenance:mode --on"

I tried the following :

docker exec -u www-data nextcloud_front_1 sh -c "php occ maintenance:mode --on"
docker exec -u www-data nextcloud_front_1 sh -c 'php occ maintenance:mode --on'
docker exec -u www-data nextcloud_front_1 php occ maintenance:mode --on

Also, running :

docker exec -u www-data nextcloud_front_1 echo 'php occ maintenance:mode --on'

Outputs as expected

php occ maintenance:mode --on

So I don't really have any idea where the error comes from...

1 Answer 1

0

I spotted a "?" at the end of my dumps name, turned out it was a ^M char induced by Notepad++ on windows (jokes on me for working on windows)

Ran

dos2unix script.sh 

And everything runs fine now.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .