corz.org text viewer..
[currently viewing: /public/linux/usr/local/bin/mysql_backup.sh - raw]
#!/bin/bash

# simple MySQL backup..
# backup a single database, gzipped to a date-named folder
# designed to be run twice per day (folders named am/pm)

# cron something like this..
# 0 0,12 * * * /home/corzorg/bin/mysql_backup.sh

# corz.org
# ;o)

# database details
username='corz_corzorg'
password='p4$$m03&'
database='corz_corzorg'

# main backup folder on web server
home='/bax'

# sub-folder for mysql backups
baxdir='mysql'

# if you alter this, test it.
d=`date +%y.%m.%d_%P`

cd $home
mkdir -p $baxdir/$d

  echo $database
  mysqldump --add-drop-table --allow-keywords --databases -q -a -c -u$username -p$password $database > $baxdir/$d/$database.sql
  rm -f $baxdir/$d/$database.sql.gz
  gzip -9 $baxdir/$d/$database.sql

# fin

Welcome to corz.org!

Bugs? What bugs? Juggling two energetic boys (of very different ages) on Coronavirus lockdown, I'm unlikely to have them all fixed any time soon. Mail me! to prioritise!