[RDD] Sorry slightly off-topic

Gareth Lapworth gareth at gbgsolutions.com
Sat Nov 3 20:47:30 EDT 2007


Hi All,

WRT Backing up your database, I would suggest automating it with a
simple script instead of copying the /var/lib/mysql directories.  If you
take a copy of the raw database files, you can risk corrupting them.
It's far more efficient to use the mysqldump command and makes importing
and exporting far less complex.

---
/bin/db_backup.sh
--
#!/bin/sh

MyDate='/bin/date +%m-%d-%y'
MyLocation='/var/rd_sql_backups'

/usr/bin/mysqldump --opt --all-databases -u root -p YOURPASSWORDHERE >
"$MyLocation"/db-`$MyDate`.sql

---

I then generally whack this into a crontab to run everyday at 8pm.  I
have another script that runs once a month, to archive the backups and
delete the older ones which are stored on tape too.

If your database is lost, you are easily able to restore it using the
command :

mysql -u root -p YOURPASSWORDHERE
< /var/rd_sql_backups/db-04-11-2007.sql

Assuming that 04-11-2007 is the date and filename of the backup you
would like to import.

This script expects there to be a /var/rd_sql_backups directory with the
correct permissions.

Hope this helps

Gareth





--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Mail delivered by GBG Solutions mail services.
http://www.gbgsolutions.com



More information about the Rivendell-dev mailing list