Friday, April 18, 2008

Quick and Dirty Mysql backup to Samba share

#mount the samba share

mount -t smbfs -o username=<username>,password=<password> //server/share /mnt/database

#backup database

for i in $(mysql-uroot -password -e "SHOW DATABASES"|tail +2); do mysqldump -uroot -ppassword $i | gzip -9 > /mnt/database/$i.sql.gz; done

#unmount the samba share
umount /mnt/database

No comments: