Skip to content

Commit

Permalink
v2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
brettwilcox committed Feb 24, 2019
1 parent ea637a0 commit 1d9cf67
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Change Log

## 2.5 - (2006-01-15)
- Added support for setting MAXIMUM_PACKET_SIZE and SOCKET parameters. (suggested by Yvo van Doorn)

## 2.4 - (2006-01-23)
- Fixed bug where weekly backups were not being rotated. (fix by wolf02)
- Added hour an min to backup filename for the case where backups are taken multiple times in a day.
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ To set the day of the week that you would like the weekly backup to happen set t

`LATEST` is to store an additional copy of the latest backup to a standard location so it can be downloaded by thrid party scripts.

### Blob

If the DB's being backed up make use of large `BLOB` fields then you may need to increase the `MAX_ALLOWED_PACKET` setting, for example 16MB.

### Socket

When connecting to localhost as the DB server (`DBHOST=localhost`) sometimes the system can have issues locating the socket file. This can now be set using the `SOCKET` parameter. An example may be

SOCKET=/private/tmp/mysql.sock

### Pre-Backup and Post-Backup Scripts

Use `PREBACKUP` and `POSTBACKUP` to specify Per and Post backup commands or scripts to perform tasks either before or after the backup process.
Expand Down
31 changes: 28 additions & 3 deletions automysqlbackup.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
#
# MySQL Backup Script
# VER. 2.4 - http://sourceforge.net/projects/automysqlbackup/
# VER. 2.5 - http://sourceforge.net/projects/automysqlbackup/
# Copyright (c) 2002-2003 [email protected]
#
# This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -82,6 +82,12 @@ COMMCOMP=no
# Additionally keep a copy of the most recent backup in a seperate directory.
LATEST=no

# The maximum size of the buffer for client/server communication. e.g. 16MB (maximum is 1GB)
MAX_ALLOWED_PACKET=

# For connections to localhost. Sometimes the Unix socket file must be specified.
SOCKET=

# Command to run before backups (uncomment to use)
#PREBACKUP="/etc/mysql-backup-pre"

Expand Down Expand Up @@ -177,6 +183,13 @@ LATEST=no
# LATEST is to store an additional copy of the latest backup to a standard
# location so it can be downloaded bt thrid party scripts.
#
# If the DB's being backed up make use of large BLOB fields then you may need
# to increase the MAX_ALLOWED_PACKET setting, for example 16MB..
#
# When connecting to localhost as the DB server (DBHOST=localhost) sometimes
# the system can have issues locating the socket file.. This can now be set
# using the SOCKET parameter.. An example may be SOCKET=/private/tmp/mysql.sock
#
# Use PREBACKUP and POSTBACKUP to specify Per and Post backup commands
# or scripts to perform tasks either before or after the backup process.
#
Expand Down Expand Up @@ -229,6 +242,8 @@ LATEST=no
# Change Log
#=====================================================================
#
# VER 2.5 - (2006-01-15)
# Added support for setting MAXIMUM_PACKET_SIZE and SOCKET parameters (suggested by Yvo van Doorn)
# VER 2.4 - (2006-01-23)
# Fixed bug where weekly backups were not being rotated. (Fix by wolf02)
# Added hour an min to backup filename for the case where backups are taken multiple
Expand Down Expand Up @@ -327,7 +342,7 @@ DNOW=`date +%u` # Day number of the week 1 to 7 where 1 represents Monday
DOM=`date +%d` # Date of the Month e.g. 27
M=`date +%B` # Month e.g January
W=`date +%V` # Week Number e.g 37
VER=2.4 # Version Number
VER=2.5 # Version Number
LOGFILE=$BACKUPDIR/$DBHOST-`date +%N`.log # Logfile Name
LOGERR=$BACKUPDIR/ERRORS_$DBHOST-`date +%N`.log # Logfile Name
BACKUPFILES=""
Expand All @@ -339,6 +354,12 @@ if [ "$COMMCOMP" = "yes" ];
OPT="$OPT --compress"
fi

# Add --compress mysqldump option to $OPT
if [ "$MAX_ALLOWED_PACKET" ];
then
OPT="$OPT --max_allowed_packet=$MAX_ALLOWED_PACKET"
fi

# Create required directories
if [ ! -e "$BACKUPDIR" ] # Check Backup Directory exists.
then
Expand Down Expand Up @@ -388,7 +409,7 @@ mysqldump --user=$USERNAME --password=$PASSWORD --host=$DBHOST $OPT $1 > $2
return 0
}

# Compression function
# Compression function plus latest copy
SUFFIX=""
compression () {
if [ "$COMP" = "gzip" ]; then
Expand Down Expand Up @@ -437,6 +458,9 @@ fi
# Hostname for LOG information
if [ "$DBHOST" = "localhost" ]; then
HOST=`hostname`
if [ "$SOCKET" ]; then
OPT="$OPT --socket=$SOCKET"
fi
else
HOST=$DBHOST
fi
Expand Down Expand Up @@ -639,6 +663,7 @@ then
else
if [ -s "$LOGERR" ]
then
cat "$LOGFILE"
echo
echo "###### WARNING ######"
echo "Errors reported during AutoMySQLBackup execution.. Backup failed"
Expand Down

0 comments on commit 1d9cf67

Please sign in to comment.