Last change
on this file since 357 was 344, checked in by Rick van der Zwet, 13 years ago |
Avoid potential directory disaster.
|
-
Property svn:executable
set to
*
|
File size:
651 bytes
|
Rev | Line | |
---|
[343] | 1 | #!/bin/sh
|
---|
| 2 | #
|
---|
| 3 | # $Id: mysqlbackup.sh 8624 2010-10-31 23:16:34Z rick $
|
---|
| 4 | # Poor mans mysql database backup.
|
---|
| 5 | # Rick van der Zwet <info@rickvanderzwet.nl>
|
---|
| 6 |
|
---|
| 7 |
|
---|
| 8 | BACKUP_ROOT="/usr/backup/`hostname -s`/mysqlbackup"
|
---|
| 9 | MYSQL_AUTH=`cat /root/.mysql_root_auth` || exit 1
|
---|
| 10 | export PATH=$PATH:/usr/local/bin
|
---|
| 11 |
|
---|
| 12 | # All available database
|
---|
| 13 | DATABASES=`echo 'show databases' | mysql --skip-column-names $MYSQL_AUTH`
|
---|
| 14 |
|
---|
| 15 | BACKUP_TODAY=`date "+$BACKUP_ROOT/%Y/%m/%d/"`
|
---|
[344] | 16 | mkdir -p $BACKUP_TODAY || exit 1
|
---|
[343] | 17 | # Dump and compress
|
---|
| 18 | for DATABASE in $DATABASES; do
|
---|
| 19 | TIMETAG=`date "+%H:%M:%S"`
|
---|
| 20 | mysqldump $MYSQL_AUTH --skip-lock-tables $DATABASE | gzip > $BACKUP_TODAY/$DATABASE-$TIMETAG.sql.gz
|
---|
| 21 | done
|
---|
Note:
See
TracBrowser
for help on using the repository browser.