-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix output dir, add quiet mode. #3
Conversation
Previously the script would determine its own location instead of using the current working directory, in contrast to what the comment above that line of code expressed. Trying to create a directory at the location of the script itself is not a good idea anyway and will usually fail if the script is placed e. g. in a place like /usr/local/bin.
* Adds a -q switch to suppress all output in case of regular successful runs. This makes the script much more suitable for unattended runs via cron where any other output would usually cause a notification mail. * Adds a -n switch to optionally skip the reverse IP address lookup.
New options -r (rotating backups, keeping up to n previous files) and -c for providing a mysql configuration file with credentials to be used. Allows storing these in a protected file instead of having to provide it via script parameter (which might be logged somewhere) or requiring interactive entry. Using the --defaults-extra-file option for the mysql clients requires some working around quoting issues (hence eval). Moreover, the option needs to be the first.
Thank you very much for your improvements! |
echo -n "${i_percent}%" | ||
else | ||
if [ $(($i_percent % 2)) -eq 0 ]; then echo -n "."; fi | ||
TABLE_DUMP_CMD="mysqldump ${MYSQL_CONN} --routines --opt --single-transaction --skip-lock-tables $dump_opt $DBNAME --tables ${table}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm getting this error when not using the conf file.
# ./zabbix-mysql-dump -n -h 127.0.0.1 -u zabbix -pzabbix -d zabbix -o /root/
Configuration:
- host: 127.0.0.1 (127.0.0.1)
- database: zabbix
- user: zabbix
Fetching list of existing tables...
Starting table backups...
mysqldump: Couldn't find table: "zabbix"
Failed dumping table acknowledges. Aborting.
I found that
The TABLE_DUMP_CMD is like this mysqldump -h 127.0.0.1 -u zabbix -pzabbix zabbix --routines --opt --single-transaction --skip-lock-tables --no-data zabbix --tables acknowledges
Where zabbix
appears two times, and the command tries to find a table named zabbix
, and ends with an error.
I suggest, for an easy merge by the maintainers, split in different PRs. Individual PRs for:
|
@endersonmaia Thank you for your comments! Sorry I left this request open for so long. Splitting the patch up would indeed help me, as the fault you pointed out has to be fixed. |
I incorporated all changes but had to rewrite quite some of the code. The new release is available here: https://github.com/maxhq/zabbix-backup/releases/tag/v0.8.0 |
See commit comments for the reasoning behind these changes.