[PLUG] MySQL v. PostgreSQL -- perhaps an easy answer
Wil Cooley
wcooley at nakedape.cc
Thu Jan 15 00:03:02 UTC 2004
On Wed, 2004-01-14 at 14:39, Jeme A Brelin wrote:
> Which is easier for backups?
>
> I assume that, with either one, you just want to stop the dbms and dump to
> a file and back that up. Am I wrong?
>
> I guess this is where y'all tell me I should be using LVM?
Both are fairly straightforward, provided your databases aren't
monstrous and you can spare a few seconds of downtime. Here's a backup
script I use (OpenLDAP backups included for extra flavour):
#########################################
#!/bin/bash
renice +19 -p $$ >/dev/null 2>&1
lf=/var/lock/$(basename $0)
if [ -e ${lf} ]; then
print "Error: Lock file ${lf} already exists!"
exit 1
fi
touch ${lf}
backupdir=/var/backups/
pgbkdir=${backupdir}/pgsql/
pgbk=${pgbkdir}/$(date -I).sql
mybkdir=${backupdir}/mysql/
mybk=${mybkdir}/$(date -I).sql
ldapbkdir=${backupdir}/ldap/
ldapbk=${ldapbkdir}/$(date -I).ldif
# * Postgres database *
if [ -e ${pgbk} -o -e ${pgbk}.bz2 ]; then
printf "Not dumping Postgres databases--${pgbk} already exists\n"
else
su postgres -c "pg_dumpall >${pgbk}"
bzip2 -9 ${pgbk}
find ${pgbkdir} -mtime +7|xargs -r rm -f
fi
# * MySQL database *
if [ -e ${mybk} -o -e ${mybk}.bz2 ]; then
printf "Not dumping MySQL databases--${mybk} already exists\n"
else
mysqldump -Aa > ${mybk}
bzip2 -9 ${mybk}
find ${mybkdir} -mtime +7|xargs -r rm -f
fi
# * OpenLDAP database *
if [ -e ${ldapbk} -o -e ${ldapbk}.bz2 ]; then
printf "Not dumping OpenLDAP databases--${ldapbk} already exists\n"
else
service ldap stop
slapcat -l ${ldapbk}
service ldap start
bzip2 -9 ${ldapbk}
find ${ldapbkdir} -mtime +7|xargs -r rm -f
fi
rm -f ${lf}
#########################################
Wil
--
Wil Cooley wcooley at nakedape.cc
Naked Ape Consulting http://nakedape.cc
* * * * * * * Good, fast and cheap: Pick all 3! * * * * * * *
* Naked Ape Consulting http://nakedape.cc *
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.pdxlinux.org/pipermail/plug/attachments/20040115/6a505641/attachment.asc>
More information about the PLUG
mailing list