This is a simple script to back up a MySQL database by creating a text dump of all the tables. It is based on a script I found on the The PHP Cult.
#!/bin/bash user=USERNAME; password=PASSWORD; tmp=BACKUP_DIRECTORY; dblist=$tmp/dblist.txt mkdir $tmp /usr/bin/mysql -e "show databases" -u $user --password=$password | sed s/^Database//g | sed s/\|//g | sed s/\ //g > $dblist for i in `cat $dblist` do export FILENAME1="$i.sql" echo "Backing up $i to $FILENAME1 ...." /usr/bin/mysqldump -u $user --opt --password=$password $i > $tmp/$FILENAME1 done
No comments:
Post a Comment