by Peter West.
Just saw this while browsing.
With respect to:
mysqldump -u moodleuser -p'pw' moodle > /var/www/moodlebu/mdldb-$(date +%Y%m%d%_-H%M%S).sqlyou can always try the embedded command ('date' in this case) from the command line, like so
$ date +%Y%m%d%_-H%M%S
For me, that gives
20160912-H2924
Note the 'H'. That's happening because you don't have a '%' in front of the 'H' in the command. As you noted, the '_' is not appearing in the output. That's because you do have a % in front of the '_'. date tries to interpret all characters with a preceding '%' as format specifiers. It doesn't know any format associated with '%_" so it just drops it.
The correct date command involves shifting the errant %. You can try from the command line
$ date +%Y%m%d_-%H%M%S
which gives me
20160912_-232952
The command line is very picky about the commands it receives.
Incidentally, you mentioned in your initial post that you got an error message about an unrecognised argument '--'. I suspect that you had a space between the '--' and the argument name for one of your arguments.