I am running mariadb in a docker container and I am try to back it up via cron and a bash script. I can't figure out the correct syntax of the ' and "
This is what I want to do, this works when I insert it into my terminal:
docker exec mariadb sh -c 'exec mysqldump --single-transaction -u myDb_user -p"secret" myDb' > tmp.sql
This is the line of code which causes the error in my bash script (should do the exact same thing than the line above, but in a bash script and with a few variables (need to back up multiple things):
#!/bin/bash
...
docker exec mariadb sh -c 'exec mysqldump --single-transaction -u ${dbUser} -p"${dbPassword}" ${database}' > "${backupdir}/${fileNameBackupDb}"
The output when I run the bash script (via sudo ./backup.sh)
Usage: mysqldump [OPTIONS] database [tables]
OR mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
OR mysqldump [OPTIONS] --all-databases [OPTIONS]
For more options, use mysqldump --help