source: tools/mysql-snapshot.sh@ 373

Last change on this file since 373 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
Line 
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
8BACKUP_ROOT="/usr/backup/`hostname -s`/mysqlbackup"
9MYSQL_AUTH=`cat /root/.mysql_root_auth` || exit 1
10export PATH=$PATH:/usr/local/bin
11
12# All available database
13DATABASES=`echo 'show databases' | mysql --skip-column-names $MYSQL_AUTH`
14
15BACKUP_TODAY=`date "+$BACKUP_ROOT/%Y/%m/%d/"`
16mkdir -p $BACKUP_TODAY || exit 1
17# Dump and compress
18for 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
21done
Note: See TracBrowser for help on using the repository browser.