Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have this MySQL backup script that I use to back up MySQL databases. Very useful, and it runs on fixed intervals using a cron. However, I need somehow provide this script with the MySQL password. This password is not the same on every server, but as I manage several servers, this particular script is part of a git-controlled repository that is synced together with some other scripts occasionally. Now, my question is: how can I use this same script as part of a git repo, if the password is different? The solution I can come up with is defining the password as an external/global variable in shell, rather than in the script itself, and that way my script can remain the same on every server. However, I am not sure what the proper way is to do so, nor am I sure if this is a good idea (security/best practices-wise).

Any thoughts?

share|improve this question
up vote 1 down vote accepted

Well, at least keeping passwords in git is surely a bad idea.

It'd be better using .config file for that. Also it's neat to have some .config-example added to git but with different extension and not real passwords of course — it allows for synchronizing changes regarding to those variables in code and config, also such .config-example can be used as starting point for new installation, for e. g..

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.