Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 21

Thread: automysql backup

  1. #11

    Default Re: automysql backup

    Hi John,

    that should be something to consider.
    but what about emailing.
    and furthermore how can i write such a script?
    i have no experience writing binary scripts.

    that's why i was looking for a out-of-the-box application such as automysqlbackup and phpmysqlbackup.

    kind regards,
    Arnold

  2. #12
    Join Date
    Jan 2009
    Location
    Switzerland
    Posts
    1,529

    Default Re: automysql backup

    Hi arnoldnijboer

    Even if it says somewhere that automysqlbackup.sh is not supported that's no problem. Shell scripts are easy ho debug and hack.

    Looking closely at the code it seems to me that line 641 of the script is buggy. It looks like this:

    Code:
    ATTSIZE=`du -c $BACKUPFILES | grep "[[:digit:][:space:]]total$" |sed s/\s*total//`
    This will fail if your locale is not set to english. You can check this if you issue the following command from the commandline:

    Code:
    du -c somefile1 somefile2
    Fix the respective line with your favorite editor to read:

    Code:
    ATTSIZE=$(du -c $BACKUPFILES | tail -n 1 | sed -e "s/\\t.*//")
    There remains the problem that your backups return errors at some point. Comment line 686 of the script to read:

    Code:
    #eval rm -f "$LOGERR"
    and then after running the script have a look at the file in your backup directory named ERROR_<something>.log and post it's contents (or part of it in case it's too long).

    I'm absolutely sure that we get this running.

  3. #13
    Join Date
    Jun 2008
    Location
    /dev/belgium
    Posts
    1,946

    Default Re: automysql backup

    I've written a cron script for MySQL backups which I've been using for years now without a problem. It has a config file in /etc/dumpmysql where one can configure stuff. It's in my repo and is called... emmm... "dumpmysql"

  4. #14

    Default Re: automysql backup

    Hey Vodoo,

    thanks for you're help... a 1000 thanks.
    it's working now.

    for other people. the problem was:
    mutt wasn't installed

    and after commenting out the removal off the error file,
    i could read the errors. weird do! that standard the error file is removed.

    Kind regards.
    Arnold

  5. #15
    Join Date
    Jun 2008
    Location
    /earth/europe/uk/england/west-yorkshire/leeds/mystreet/myhouse
    Posts
    248

    Default Re: automysql backup

    Taken from the automysqlbackup.sh file:-

    # The MAILCONTENT and MAILADDR options and pretty self explanitory, use
    # these to have the backup log mailed to you at any email address or multiple
    # email addresses in a space seperated list.
    # (If you set mail content to "log" you will require access to the "mail" program
    # on your server. If you set this to "files" you will have to have mutt installed
    # on your server. If you set it to "stdout" it will log to the screen if run from
    # the console or to the cron job owner if run through cron. If you set it to "quiet"
    # logs will only be mailed if there are errors reported. )

    I found this thread while posting about another (unrelated SQL question) and I wanted to automate my MySQL backups, this script seems to work fine and emailing the SQL files and logs to me fine (once Mutt was installed).

  6. #16
    Join Date
    Jan 2009
    Location
    Switzerland
    Posts
    1,529

    Thumbs down Re: automysql backup

    Quote Originally Posted by arnoldnijboer View Post
    Hey Vodoo,

    thanks for you're help... a 1000 thanks.
    it's working now.

    for other people. the problem was:
    mutt wasn't installed

    and after commenting out the removal off the error file,
    i could read the errors. weird do! that standard the error file is removed.

    Kind regards.
    Arnold
    Last note from my side: The script uses a rather strange way to generate a unique filename in lines 346 and 347. If you keep the logs and list them with ls -l it will not show them in the correct (chronological) order and there is a remote chance to overwrite one of the files.

    I would change this to:

    Code:
    LOGERR=$BACKUPDIR/ERRORS_$DBHOST-`date +%Y%m%d-%H%M%S`.log
    No one is likely to run the backups twice within one second (unless you have a few thousand users on your system doing backups, grin). The reason why the author choose to remove the error log probably is because this file is created each time even if it's empty. The script would gradually fill the /backup directory with empty logfiles. It would probably be much better to conditionally remove the logfile only if it is empty.

    Something like this:

    Code:
    if ! test -s "$LOGERR" ; then
         eval rm -f "$LOGERR"
    fi

  7. #17

    Default Re: automysql backup

    those are some great suggestions Vodoo!

    and i really don't wanna push you're great help.
    but do you think it is possible to get 1 error file (apache style)
    like.
    date ... error ...
    date2 .. error2 ..
    ...
    ...

    kind regards,
    Arnold

  8. #18
    Join Date
    Jan 2009
    Location
    Switzerland
    Posts
    1,529

    Default Re: automysql backup

    Well, that would require some changes in the design of the script. It starts with a fresh error logfile because it wants to test later on if this file is still of length zero. Keeping a single logfile would break this.

    But you can try to add the contents of the session logfile to a general logfile before deleting the session logfile.

    Re-enable the deletion of the logfile and just before this happens add this (last line already present):

    Code:
    date >> $BACKUPDIR/GENERAL_ERRLOG_$DBHOST.log
    cat "$LOGERR" >> $BACKUPDIR/GENERAL_ERRLOG_$DBHOST.log
    eval rm -f "$LOGERR"
    It can't break a lot, try it and have fun. If it doen't work feel free to complain and we will fix it.

  9. #19

    Default Re: automysql backup

    Okey Vodoo,

    i've put some logic thinking into you're script and modified it.
    else i'm getting 1 big log file with only dates.
    i hope it wil now only log errors.
    and if no errors then does nothing to the logfile.

    can you confirm my d.i.y. coding?

    if ! test -s "$LOGERR" ;
    then
    eval rm -f "$LOGERR"
    else
    date >> $BACKUPDIR/GENERAL_ERRLOG_$DBHOST.log
    cat "$LOGERR" >> $BACKUPDIR/GENERAL_ERRLOG_$DBHOST.log
    eval rm -f "$LOGERR"
    fi

  10. #20
    Join Date
    Jan 2009
    Location
    Switzerland
    Posts
    1,529

    Default Re: automysql backup

    Yep, this should work, but I would turn it the other way round for clarity. test -s means, the file exists and has a size greater than zero. That's the case when we add the session error log to the general log preceeded by the date.

    Code:
    if test -s "$LOGERR" ; then
        date >> $BACKUPDIR/GENERAL_ERRLOG_$DBHOST.log
        cat "$LOGERR" >> $BACKUPDIR/GENERAL_ERRLOG_$DBHOST.log
    fi
    eval rm -f "$LOGERR"
    Note the following: when you prefer to write 'then' on a new line the semicolon ';' is not needed. And I guess that 'eval' can just as well be omitted. Welcome to the wonderful world of bash-scripting.

Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •