Menu

#62 post backup

closed
nobody
5
2012-03-05
2012-01-23
Anonymous
No

Good day,

I noticed that on postbackup all output is put in the $err_logfile file.
Then it says that the backup = failed because it has output from the script in it :D

I fixed it myself by backing the file up in the postbackup script then copying it back when exit=0 after the post backup.
But i can imagine that it shoud work normaly and display the output of the postbackup script instead of a failed message.

great work on the script i really love it!

Discussion

  • PittaGurneyi

    PittaGurneyi - 2012-01-23

    I'm afraid I don't follow.
    Once it is clear, that the requirements for I/O redirection are met, all output that goes to stdout and stderr is redirected to the appropriate logfiles. In case you choose an output method that mails stuff, these logfiles are mailed as attachments, or simply displayed to your "normal" stdin.
    The postbackup and prebackup scripts are sourced, which means, that they are treated as any code inserted in place of the "source postbackup_script" line. No special treatment of this stuff is done, aside from checking that the postbackup variable contains a readable file - securing this stuff is your business. If you would therefore clarify what you think should happen instead of what happens, I would perhaps be able to help you.

     
  • PittaGurneyi

    PittaGurneyi - 2012-01-23

    About these jpg files that are really html files: I have removed them. You upload files again, which contents don't match their extensions, I will be more than unhappy.

     
  • Anonymous

    Anonymous - 2012-01-24

    The file is a jpg that's for sure. i have it here.. but once i upload it changes for some way..

    let me try to explain:
    I have a postbackup script thats readable and executable.
    i have further no config the reason i recieve mail with output is only becouse i have the script in my crontab and output from that is always mailed to root.

    But the output of my script is being put in the $errlog_file. i have not defined any redirections for logging its just stdout. (on screen). but the mysqlbackup script just puts the output in the $errlog_file. further i dont understand "source postback_script".

     
  • PittaGurneyi

    PittaGurneyi - 2012-01-24

    Where do you run this post-backup.sh file?

     
  • PittaGurneyi

    PittaGurneyi - 2012-01-24

    Do you have
    CONFIG_postbackup="/folder/to/post-backup.sh"
    set?
    If so and you still have problems, use a test script:
    #!/bin/bash
    echo "stdout" >&1
    echo "stderr" >&2

    Make it executable and put its location in this variable. Run the script. Then you will see a line stdout in the normal output and the line stderr in the error email. Therefore, if you have those lines
    Warning: It is insecure ...
    in the error email, that means that your script outputs stuff to stderr, which is redirected to the err_logfile.

     
  • Anonymous

    Anonymous - 2012-01-25

    I have set CONFIG_postbackup.

    i will test your example.

    The warning rule is always there when u encrypt a file with mcrypt.
    its not an error when i test the exit code of the mcrypt command i always end up whit 0.

    1 question tho. #!/bin/bash? i use korn shell. is that a problem?

     
  • PittaGurneyi

    PittaGurneyi - 2012-01-25

    Korn shell is not Bash. The script has to be run in bash, since it is programmed for it. In Korn shell unexpected behavior will occur. Also the automysqlbackup script uses "source" to load the contents of the CONFIG_postbackup file and execute it in its working environment - therefore it is executed by bash, if automysqlbackup is executed by bash. Therefore, the code you supply by this CONFIG_postbackup script has to be BASH!!! This entry point has been created to have access to the config AND runtime variables. If your script doesn't need it, use a wrapper (for example the cron script) to achieve your goal.

    Do the following:
    mcrypt ... 2>/tmp/stderr_log >/tmp/stdout_log
    This redirects the stdout to /tmp/stdout_log and stderr to /tmp/stderr_log.
    If ANYTHING ends up in stderr_log, then - independent of what the exit code is -, mcrypt outputs stuff to stderr - even the warning!

     
  • PittaGurneyi

    PittaGurneyi - 2012-01-27

    Would you mind telling me if this now worked, if you found a solution to your problem and if so, what is it? Then I could close this bug and remove it from memory.

     
  • PittaGurneyi

    PittaGurneyi - 2012-03-05
    • status: open --> closed
     

Log in to post a comment.