Skip to content

Commit 6a41417

Browse files
v3.0_rc6
1 parent 543b370 commit 6a41417

File tree

5 files changed

+3372
-3
lines changed

5 files changed

+3372
-3
lines changed

CHANGELOG

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
#=====================================================================
2+
# Change Log
3+
#=====================================================================
4+
#
5+
# version 3.0_rc4 - (2011-11-24)
6+
# - Removing mkfifo commands, thereby improving portability.
7+
# - Fixing not working table exclude feature for wildcards.
8+
# version 3.0_rc3 - (2011-11-24)
9+
# - Changed code to make it more portable, thereby resolving FreeBSD issue.
10+
# version 3.0_rc2 - (2011-11-21)
11+
# - Added multicore support for bzip and gzip2.
12+
# - Fixed error in README file.
13+
# version 3.0_rc1 - (2011-11-15)
14+
# - Added differential backup method.
15+
# - Added user-friendly method to recreate full backups out of differential ones.
16+
# - Changed paramters, with which the script can be called, to make the new
17+
# methods available.
18+
# - Fixed some bugs.
19+
# version 3.0_beta2 - (2011-08-21)
20+
# - Added possibility to backup local files.
21+
# - Added full schema backup.
22+
# - Added master-data option.
23+
# - Fixed some bugs.
24+
# version 3.0_beta1 - (2011-08-15)
25+
# - REMOVED: Implementation of Variables containing full path to binaries to
26+
# avoid possibly confusion with aliases or builtins. (by Johannes Kolter)
27+
# Inside a bash script no aliases are used! This didn't make ANY sense!
28+
# Thereby resolved bug item #3074425.
29+
# - Changed some variables to be arrays, i.e. lists, and removed the ugly
30+
# sed stuff.
31+
# Fixed bug item #3169562
32+
# - Added check for weekly and monthly backups, so that they are unique per day.
33+
# bug item #3185389
34+
# - Changed SHEBANG to #!/usr/bin/env bash for portability reasons.
35+
# bug item #3292873
36+
# - Changed config file structure: read /etc/automysqlbackup/mysqlbackup.conf,
37+
# if supplied read configfile parameter (no more -c or sth. like that, just
38+
# the name of the file!),
39+
# whatever isn't set yet, set in here to default values.
40+
# - bug item #3110715: create a file in /etc/cron.d/daily and call the script
41+
# from in there, i.e. place the script in /usr/local/bin
42+
# - bug item #3082899: the PATH variables are different in ssh, you have to
43+
# supply the complete path
44+
# - Fixed bug item #3064547, suggestion accepted.
45+
# - Fixed bug item #3031023, suggestion accepted.
46+
# - Fixed bug item #3030604, resolved due to design correction.
47+
# - Fixed bug item #3025849, as long as basename is in $PATH on your system.
48+
# - Fixed bug item #3030478.
49+
# - bug item #3054633: .muttrc entry save=yes will result in saving sent files!
50+
# - Feature request item #1538588.
51+
# - Feature request item #1538138.
52+
# - Feature request item #1538142.
53+
# - Feature request item #1541843 was already included.
54+
# - Feature request item #2808012.
55+
# - Feature request item #2831465.
56+
# - Feature request item #3052484. Mysqldump already has an ssl option.
57+
# - Feature request item #3190079. I hope cleaning up everything older than 24
58+
# hours as a lower limit is good enough.
59+
# - Feature request item #3284779 was already included. See CONFIG_mysql_dump_latest.
60+
# - Feature request item #3053623.
61+
# version 2.6.0 - (2011-07-19)
62+
# - Fixed bug where files would not email correctly (Fix by Jesse Vaughan)
63+
# - Added section to encrypt .gz and .bz2 files using openssl (added by Jesse Vaughan)
64+
# version 2.5.1-01 - (2010-07-06)
65+
# - Fixed pathname bug item #3025849 (by Johannes Kolter)
66+
# version 2.5.1 - (2010-07-04)
67+
# - Added support for default and optional config file (by Johannes Kolter)
68+
# - Rotating after backup was successful whith find(1) (by Johannes Kolter)
69+
# - Implementation of Variables containing full path to binaries to
70+
# avoid possibly confusion with aliases or builtins. (by Johannes Kolter)
71+
# - Fixed bug where weekly backups were not being rotated.
72+
# Added rotation of 5 monthly backups
73+
# Now all old backups are deleted, not only the most recent one
74+
# (inspired by [email protected])
75+
# - Use Debian special-file to access database (by Johannes Kolter)
76+
# - Fixed bug ID: 1438565
77+
# Moved IO redirection to a place before decicions are made and actions are taken.
78+
# (inspired by Derk Bernhardt)
79+
# - Fixed bug ID: #3000316 (reported by Sascha Feldhorst)
80+
# - Fixed bug ID: #1529458 (reported by Natalie ( njwood ))
81+
# - Fixed bug ID: #1548919 (reported by Piotr Kuczynski)
82+
# version 2.5 - (2006-01-15)
83+
# Added support for setting MAXIMUM_PACKET_SIZE and CONFIG_mysql_dump_socket parameters (suggested by Yvo van Doorn)
84+
# version 2.4 - (2006-01-23)
85+
# Fixed bug where weekly backups were not being rotated. (Fix by wolf02)
86+
# Added hour an min to backup filename for the case where backups are taken multiple
87+
# times in a day. NOTE This is not complete support for mutiple executions of the script
88+
# in a single day.
89+
# Added MAILCONTENT="quiet" option, see docs for details. (requested by snowsam)
90+
# Updated path statment for compatibility with OSX.
91+
# Added "CONFIG_mysql_dump_latest" to additionally store the last backup to a standard location. (request by Grant29)
92+
# version 2.3 - (2005-11-07)
93+
# Better error handling and notification of errors (a long time coming)
94+
# Compression on Backup server to MySQL server communications.
95+
# version 2.2 - (2004-12-05)
96+
# Changed from using depricated "-N" to "--skip-column-names".
97+
# Added ability to have compressed backup's emailed out. (code from Thomas Heiserowski)
98+
# Added maximum attachment size setting.
99+
# version 2.1 - (2004-11-04)
100+
# Fixed a bug in daily rotation when not using gzip compression. (Fix by Rob Rosenfeld)
101+
# version 2.0 - (2004-07-28)
102+
# Switched to using IO redirection instead of pipeing the output to the logfile.
103+
# Added choice of compression of backups being gzip of bzip2.
104+
# Switched to using functions to facilitate more functionality.
105+
# Added option of either gzip or bzip2 compression.
106+
# version 1.10 - (2004-07-17)
107+
# Another fix for spaces in the paths (fix by Thomas von Eyben)
108+
# Fixed bug when using PREBACKUP and POSTBACKUP commands containing many arguments.
109+
# version 1.9 - (2004-05-25)
110+
# Small bug fix to handle spaces in LOGFILE path which contains spaces (reported by Thomas von Eyben)
111+
# Updated docs to mention that Log email can be sent to multiple email addresses.
112+
# version 1.8 - (2004-05-01)
113+
# Added option to make backups restorable to alternate database names
114+
# meaning that a copy of the database can be created (Based on patch by Rene Hoffmann)
115+
# Seperated options into standard and advanced.
116+
# Removed " from single file dump DBMANES because it caused an error but
117+
# this means that if DB's have spaces in the name they will not dump when CONFIG_mysql_dump_use_separate_dirs=no.
118+
# Added -p option to mkdir commands to create multiple subdirs without error.
119+
# Added disk usage and location to the bottom of the backup report.
120+
# version 1.7 - (2004-04-22)
121+
# Fixed an issue where weelky backups would only work correctly if server
122+
# locale was set to English (issue reported by Tom Ingberg)
123+
# used "eval" for "rm" commands to try and resolve rotation issues.
124+
# Changed name of status log so multiple scripts can be run at the same time.
125+
# version 1.6 - (2004-03-14)
126+
# Added PREBACKUP and POSTBACKUP command functions. (patch by markpustjens)
127+
# Added support for backing up DB's with Spaces in the name.
128+
# (patch by markpustjens)
129+
# version 1.5 - (2004-02-24)
130+
# Added the ability to exclude DB's when the "all" option is used.
131+
# (Patch by kampftitan)
132+
# version 1.4 - (2004-02-02)
133+
# Project moved to Sourceforge.net
134+
# version 1.3 - (2003-09-25)
135+
# Added support for backing up "all" databases on the server without
136+
# having to list each one seperately in the configuration.
137+
# Added DB restore instructions.
138+
# version 1.2 - (2003-03-16)
139+
# Added server name to the backup log so logs from multiple servers
140+
# can be easily identified.
141+
# version 1.1 - (2003-03-13)
142+
# Small Bug fix in monthly report. (Thanks Stoyanski)
143+
# Added option to email log to any email address. (Inspired by Stoyanski)
144+
# Changed Standard file name to .sh extention.
145+
# Option are set using yes and no rather than 1 or 0.
146+
# version 1.0 - (2003-01-30)
147+
# Added the ability to have all databases backup to a single dump
148+
# file or seperate directory and file for each database.
149+
# Output is better for log keeping.
150+
# version 0.6 - (2003-01-22)
151+
# Bug fix for daily directory (Added in version 0.5) rotation.
152+
# version 0.5 - (2003-01-20)
153+
# Added "daily" directory for daily backups for neatness (suggestion by Jason)
154+
# Added CONFIG_mysql_dump_host option to allow backing up a remote server (Suggestion by Jason)
155+
# Added "--quote-names" option to mysqldump command.
156+
# Bug fix for handling the last and first of the year week rotation.
157+
# version 0.4 - (2002-11-06)
158+
# Added the abaility for the script to create its own directory structure.
159+
# version 0.3 - (2002-10-01)
160+
# Changed Naming of Weekly backups so they will show in order.
161+
# version 0.2 - (2002-09-27)
162+
# Corrected weekly rotation logic to handle weeks 0 - 10
163+
# version 0.1 - (2002-09-21)
164+
# Initial Release

README.md

Lines changed: 206 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,207 @@
1-
AutoMySQLBackup
2-
===============
1+
AutomysqlBackup
2+
-------------------------
3+
.. INDEX
4+
-------------------------
5+
Disclaimer
6+
Install
7+
Usage
8+
Configuration Options
9+
Encryption
10+
Backup rotation
11+
Restoring
312

4-
fork of http://sourceforge.net/projects/automysqlbackup/
13+
14+
15+
.. DISCLAIMER
16+
-------------------------
17+
I take no resposibility for any data loss or corruption when using this script.
18+
This script will not help in the event of a hard drive crash. If a copy of the
19+
backup has not been stored offline or on another PC. You should copy your backups
20+
offline regularly for best protection.
21+
22+
Happy backing up...
23+
24+
25+
26+
.. INSTALL
27+
-------------------------
28+
Extract the package into a directory. If you are reading this you have probably done
29+
this already.
30+
31+
To install the Automysqlbackup the easy way.
32+
1. Run the install.sh script.
33+
2. Edit the /etc/automysqlbackup/myserver.conf file to customise your settings.
34+
3. See usage section.
35+
36+
To install it manually (the hard way).
37+
1. Create the /etc/automysqlbackup directory.
38+
2. Copy in the automysqlbackup.conf file.
39+
3. Copy the automysqlbackup file to /usr/local/bin and make executable.
40+
4. cp /etc/automysqlbackup/automysqlbackup.conf /etc/automysqlbackup/myserver.conf
41+
5. Edit the /etc/automysqlbackup/myserver.conf file to customise your settings.
42+
6. See usage section.
43+
44+
45+
46+
.. USAGE
47+
-------------------------
48+
49+
Automysqlbackup can be run a number of ways, you can choose which is best for you.
50+
51+
1. Create a script as below called runmysqlbackup using the lines below:
52+
53+
#~~~~ Copy From Below Here ~~~~
54+
#!/bin/sh
55+
56+
/usr/local/bin/automysqlbackup /etc/automysqlbackup/myserver.conf
57+
58+
chown root.root /var/backup/db* -R
59+
find /var/backup/db* -type f -exec chmod 400 {} \;
60+
find /var/backup/db* -type d -exec chmod 700 {} \;
61+
62+
#~~~~~ Copy To Above Here ~~~~
63+
64+
2. Save it to a suitable location or copy it to your /etc/cron.daily folder.
65+
66+
3. Make it executable, i.e. chmod +x /etc/cron.daily/runmysqlbackup.
67+
68+
69+
The backup can be run from the command line simply by running the following command.
70+
71+
automysqlbackup /etc/automysqlbackup/myserver.conf
72+
73+
If you don't supply an argument for automysqlbackup, the default configuration
74+
in the program automysqlbackup will be used unless a global file
75+
76+
CONFIG_configfile="/etc/automysqlbackup/automysqlbackup.conf"
77+
78+
exists.
79+
80+
You can just copy the supplied automysqlbackup.conf as many times as you want
81+
and use for separate configurations, i.e. for example different mysql servers.
82+
83+
!!! NEW !!!
84+
----------
85+
As of version 3.0 we have added differential backups using the program diff. In an
86+
effort to make the reconstruction of the full archives more user friendly, we
87+
added new functionality to the script. Therefore, while preserving the old syntax,
88+
we created options for the script, so that the new functions can be accessed.
89+
90+
Usage automysqlbackup options -cblh
91+
-c CONFIG_FILE Specify optional config file.
92+
-b Use backup method.
93+
-l List manifest entries.
94+
-h Show this help.
95+
96+
If you use these options, you have to specify everything according to them and can't
97+
mix the old syntax with the new one. Example:
98+
99+
before (still valid!):
100+
101+
>> automysqlbackup "myconfig.conf"
102+
103+
now:
104+
105+
>> automysqlbackup -c "myconfig.conf" -b
106+
107+
which is equivalent to
108+
109+
>> automysqlbackup -bc "myconfig.conf"
110+
111+
or in English: The order of the options doesn't matter, however those options expecting
112+
arguments, have to be placed right before the argument (as seen above).
113+
114+
The option '-l' (List manifest entries) finds all Manifest files in your configuration
115+
directory (you need to specify your optional config file - otherwise a fallback will be
116+
used: global config file -> program internal default options). It then filters from which
117+
databases these are and presents you with a list (you can select more than one!) of them.
118+
Once you have chosen, you will be given a list of Manifest files, from which you choose
119+
again and after that from which you choose differential files. When you have completed
120+
all your selections, a list of selected differential files will be shown. You may then
121+
choose what you want to be done with/to those files. At the moment the options are:
122+
- create full backup out of differential one
123+
- remove the differential backup and its Manifest entry.
124+
125+
126+
.. CONFIGURATION OPTIONS
127+
-------------------------
128+
129+
!! "automysqlbackup" program contains a default configuration that should not be changed:
130+
131+
The global config file which overwrites the default configuration is located here
132+
"/etc/automysqlbackup/automysqlbackup.conf" by default.
133+
134+
Please take a look at the supplied "automysqlbackup.conf" for information about the configuration options.
135+
136+
Default configuration
137+
CONFIG_configfile="/etc/automysqlbackup/automysqlbackup.conf"
138+
CONFIG_backup_dir='/var/backup/db'
139+
CONFIG_do_monthly="01"
140+
CONFIG_do_weekly="5"
141+
CONFIG_rotation_daily=6
142+
CONFIG_rotation_weekly=35
143+
CONFIG_rotation_monthly=150
144+
CONFIG_mysql_dump_usessl='yes'
145+
CONFIG_mysql_dump_username='root'
146+
CONFIG_mysql_dump_password=''
147+
CONFIG_mysql_dump_host='localhost'
148+
CONFIG_mysql_dump_socket=''
149+
CONFIG_mysql_dump_create_database='no'
150+
CONFIG_mysql_dump_use_separate_dirs='yes'
151+
CONFIG_mysql_dump_compression='gzip'
152+
CONFIG_mysql_dump_commcomp='no'
153+
CONFIG_mysql_dump_latest='no'
154+
CONFIG_mysql_dump_max_allowed_packet=''
155+
CONFIG_db_names=()
156+
CONFIG_db_month_names=()
157+
CONFIG_db_exclude=( 'information_schema' )
158+
CONFIG_mailcontent='log'
159+
CONFIG_mail_maxattsize=4000
160+
CONFIG_mail_address='root'
161+
CONFIG_encrypt='no'
162+
CONFIG_encrypt_password='password0123'
163+
164+
!! automysqlbackup (the shell program) accepts one parameter, the filename of a configuration file. The entries in there will supersede all others.
165+
166+
Please take a look at the supplied "automysqlbackup.conf" for information about the configuration options.
167+
168+
169+
170+
.. ENCRYPTION
171+
-------------------------
172+
173+
To decrypt run (replace bz2 with gz if using gzip):
174+
175+
openssl enc -aes-256-cbc -d -in encrypted_file_name(ex: *.enc.bz2) -out outputfilename.bz2 -pass pass:PASSWORD-USED-TO-ENCRYPT
176+
177+
178+
179+
.. BACKUP ROTATION
180+
-------------------------
181+
182+
Daily Backups are rotated weekly.
183+
Weekly Backups are run on fridays, unless otherwise specified via CONFIG_do_weekly.
184+
Weekly Backups are rotated on a 5 week cycle, unless otherwise specified via CONFIG_rotation_weekly.
185+
Monthly Backups are run on the 1st of the month, unless otherwise specified via CONFIG_do_monthly.
186+
Monthly Backups are rotated on a 5 month cycle, unless otherwise specified via CONFIG_rotation_monthly.
187+
188+
Suggestion: It may be a good idea to copy monthly backups offline or to another server.
189+
190+
191+
192+
.. RESTORING
193+
-------------------------
194+
195+
Firstly you will need to uncompress the backup file and decrypt it if encryption was used (see encryption section).
196+
197+
eg.
198+
gunzip file.gz (or bunzip2 file.bz2)
199+
200+
Next you will need to use the mysql client to restore the DB from the sql file.
201+
202+
eg.
203+
mysql --user=username --pass=password --host=dbserver database < /path/file.sql
204+
or
205+
mysql --user=username --pass=password --host=dbserver -e "source /path/file.sql" database
206+
207+
NOTE: Make sure you use "<" and not ">" in the above command because you are piping the file.sql to mysql and not the other way around.

0 commit comments

Comments
 (0)