source: tools/mysqlbackup.sh@ 215

Last change on this file since 215 was 215, checked in by Rick van der Zwet, 14 years ago

Some backup tooling

  • Property svn:executable set to *
File size: 604 bytes
Line 
1#!/bin/sh
2#
3# $Id: mysqlbackup.sh 8548 2010-10-04 19:41:22Z rick $
4# Poor mans mysql database backup.
5# Rick van der Zwet <info@rickvanderzwet.nl>
6
7
8BACKUP_ROOT='/usr/local/backup/mysqlbackup'
9MYSQL_AUTH='-uroot'
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
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
22
Note: See TracBrowser for help on using the repository browser.