I am writing a new script for a backup solution. Now I want to get the error message, which I saw in terminal, to a log file. Therefor I want to write the output in a variable.
I wrote an error in it. The option "defaults-file" is missing a "--".
With a simple example it worked:
#!/bin/bash
log=$(date)
echo $log
This is the code snippet:
#!/bin/bash
DATE=`date +\%Y\%m\%d\%H\%M\%S`.sql
log=$(`mysqldump defaults-file=/home/user/.my.cnf cloud > backup_$DATE`)
echo $log