Pages

Showing posts with label pleask db script. Show all posts
Showing posts with label pleask db script. Show all posts

Wednesday, 13 August 2014

Backup all MySQL DB in Plesk


 
You can use the below script to take all DB backup to local folder. 
It will take compressed format. 
 
 
 
#!/bin/bash
# Jared Earle, 2008-03-28, BD-NTWK
# Set the datestamp, login credentials and backup directory
export date=$(date +\%Y\%m\%d)
export creds="-uadmin -p`cat /etc/psa/.psa.shadow`"
export backupdir="/local/backup/folder"
# delete week old files
find ${backupdir}/ -regex '.*.dump.gz' -mtime +6 -exec rm {} \;
# dump databases to the backupdir
echo "show databases;" | mysql ${creds} | egrep -v ^Database$ | \
        awk '{print "mysqldump ${creds} "$1" | \
        gzip > ${backupdir}/db-"$1"-${date}.dump.gz"}' | \
        sh
 
Thanks to http://23x.net/