-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbackup-mysql.sh
More file actions
35 lines (26 loc) · 953 Bytes
/
backup-mysql.sh
File metadata and controls
35 lines (26 loc) · 953 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#! /bin/bash
# DESC: get a backup of all mysql databases
# $Revision: 1.2 $
# $RCSfile: backup-mysql.sh,v $
# $Author: chris $
# Copyright (c) Chris Ruettimann <chris@bitbull.ch>
# This software is licensed to you under the GNU General Public License.
# There is NO WARRANTY for this software, express or
# implied, including the implied warranties of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
# along with this software; if not, see
# http://www.gnu.org/licenses/gpl.txt
### NOTE ###
# vi /root/.my.cnf
# ---
# [client]
# host=localhost
# user=your_login
# password=your_password
BDIR="/srv/backup/mysql"
test -d $BDIR || mkdir -p $BDIR
for DB in $( mysql -N -B -e "show databases" | egrep -v 'information_schema|performance_schema' )
do
mysqldump $DB --single-transaction | gzip > $BDIR/$DB.mysql.gz
done
################################################################################