How can I create nightly dumps of my MySQL databases on my Linux Plesk server?
To perform nightly database dumps on a Plesk system, create a file /etc/cron.daily/mysqldump and add the following contents:
#!/bin/bash
DUMPDIR=/var/mysqldumps
test -d ${DUMPDIR} || /bin/mkdir ${DUMPDIR}
chmod 700 ${DUMPDIR}
cd /var/lib/mysql/
for i in *
do
test -d ${i} && /usr/bin/mysqldump -uadmin
-pcat /etc/psa/.psa.shadow echo ${i}|sed -e 's////g'
| /usr/bin/bzip2 > ${DUMPDIR}/${i}.sql.bz2
done
The locations the dumps are made to can be adjusted by changing the DUMPDIR variable