[help needed] [mysql dumps/restores] [bash script] [output redirection]
Hello and thanks for opening my cry out for help. I have been searching the web for an answer to this problem but have failed to find one up to this point and am getting pretty desperate. Don't even know where to ask this question...
So here it is: I am working on a script that is supposed to automatically import a mysql dump to a temporary database, clear some sensitive data, then do a new dump and then send the cleared database to some developpers. For it I need some pretty detailed logs. Here is where I am having the problem: Code:
mysql -u $MYSQL_ROOT_USER -p$MYSQL_ROOT_PASS ${TEMP_DB} < $WORK_FILE_1 >> $LOG_FOLDER/${DATE_LOG}-movingDB.log 2>&1 Anyone has any idea what I could do or where I could ask? Thank you in advance. |
It sounds like you want detailed logging of the import process.
By default that doesn't happen. When all is successful, there is no output from the mysql command. Try adding the "-v" flag and see if that gives enough output. If not, keep adding more and see what happens. |
thank you very much for taking the time to through some advice my way. Very much appreciated. I tried what you suggested, however the verbose mode is too much. What was important for this script was to record if the command succeeds or if it fails.
So I went around it with the following: Code:
mysql -u $MYSQL_ROOT_USER -p$MYSQL_ROOT_PASS ${TEMP_DB} < $WORK_FILE_1 HOWEVER, I find it hard to believe no one ever needed this before me. I mean if in the command Code:
mysql -u $MYSQL_ROOT_USER -p$MYSQL_ROOT_PASS ${TEMP_DB} < $WORK_FILE_1 >> $LOG_FOLDER/${DATE_LOG}-movingDB.log 2>&1 Thank you. |
Yes, it's a question of what processes each part of the command line.
To start, the shell will replace any variables and set up any redirections. It then puts all the arguments into a list and starts the command, giving it the list of arguments. The command then processes the arguments. Since the redirection is handled by the shell prior to executing the command, the errors at this stage are not redirected into the log file. |
All times are GMT -5. The time now is 06:19 AM. |