This script will dump a mysql database into a given directory and keep a 7 day rolling history. Parameters should be fairly self-explanitory. This needs to be run daily via cron.
#!/bin/bash
DATE=`date +%y-%b-%d`
DESTDIR=/home/duplicity/wordpress
DATABASE=myblog
DB_USER=root
DB_PASSWORD=password
cd ${DESTDIR}
/usr/bin/mysqldump -c –user=${DB_USER} –password=${DB_PASSWORD} ${DATABASE} > \
wpdump_${DATE}
find $DESTDIR -name “wpdump*” -mtime +7 -print | xargs rm