cron

Backup your LAMP DB externally

Simple script you could drop into /etc/cron.daily/backup_db , handy for testing the exit level of mysqldump and rsync, and then rsyncing to your external server, keeps a rolling month's worth of backups.

error checked from mysqldump by testing for info in the STDERR output, and rsync tested by examining the return code ($?)


#!/bin/bash

# keeps a rolling 30 days of DB snapshots

mysqldump -uroot -pxxx mydrupal 2> /tmp/mysql-dump-fail.log |grep -v "INSERT INTO .cache"| bzip2 > /root/db_drupal-`date +%d`.sql.bz2
if [ -s /tmp/mysql-dump-fail.log ]
then

Syndicate content