Bad SysOp, obviously (me)
That variable needs to be the first one.
** I updated the previous post to reflect the corrections. Please pay attention to the script (slight changes) and the dot-my.cnf files (was missing a [server] line in both)
Bad SysOp, obviously (me)
That variable needs to be the first one.
** I updated the previous post to reflect the corrections. Please pay attention to the script (slight changes) and the dot-my.cnf files (was missing a [server] line in both)
#!/usr/bin/bash
source ~/.mautic.my.cnf
mkdir -p ~/backups/mautic/
mysqldump --defaults-file='~/.mautic.my.cnf' --single-transaction --add-drop-table $database | gzip > ~/backups/mautic/mautic-database-$(date +%Y%m%d-%H%M%S).sql>
find ~/backups/mautic -iname "mautic-database*" -mtime +30 -delete
brings that error:
stefan@mautic01:/usr/local/bin$ mautic_db_backup
/home/stefan/.mautic.my.cnf: line 1: [client]: command not found
/home/stefan/.mautic.my.cnf: line 5: [server]: command not found
.mautic.my.cnf
[client]
password="xxxxx"
user=mautic
[server]
database=mautic
Yes, execute it from the www-data user’s crontab. That is the best.
I updated the previous post.
This error come from the fact that the dot-my.cnf file isn’t a proper bash script and contain invalid bash cmd. “source” is executing that file.
The goal was to execute the “database=blah” line and load a variable named “$database”. I later used it in the mysqldump line in order to declare the proper mysql schema.
You may disregard both errors or update your script with the updated one in the previous post. It will snooze both errors and get you peace of mind.
To demonstrate it, doing this will show you your expected results and that those 2 errors are harmless:
ls -latr ~/backups/mautic/
Dear @marcus42
Thank you very much for your great support. Now all works. Great.
This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.