1. Please take a little time for this simple survey! Thank you for participating!
    Dismiss Notice
  2. Dear Pleskians, please read this carefully! New attachments and other rules Thank you!
    Dismiss Notice
  3. Dear Pleskians, I really hope that you will share your opinion in this Special topic for chatter about Plesk in the Clouds. Thank you!
    Dismiss Notice

Dumping all the mysql databases

Discussion in 'Plesk for Linux - 8.x and Older' started by garan, Apr 17, 2006.

  1. garan

    garan Guest

    0
     
    Been meaning to tidy up my database backups for a while. I noticed that the mysql backups that Plesk does only backups up the psa and associated databases (e.g. horde).

    Rather than re-invent the wheel, I took a copy of the mysqldump.sh script that's in /usr/local/psa/bin and modified it. I removed the bottom line that does the backup and replaced it with the following:
    Code:
    for dbname in ` mysqlshow -u admin --password=$admin_passwd | grep -v "+" | grep -v "Databases" | tr ["|"] [" "]`; do
      ${MYSQL_BIN_D}/mysqldump --quote-names --user=admin --password=$admin_passwd --database $dbname > /root/mysqlbackups/$dbname.sql && rotate $dbname.sql 8 7 6 5 4 3 2 1 0 ;
    done
    
    I'm not pretending that it's neat :) and welcome any comments or alternative methods..

    Cheers,

    Garan.
     
  2. wagnerch

    wagnerch Guest

    0
     
    How about ...

    mysqldump --quote-names --user=admin --password=$admin_passwd --all-databases

    Only difference is it will create one backup of all databases. It is fairly easy to split out one database, if needed.
     
  3. garan

    garan Guest

    0
     
    I did think about doing it that way but decided to go for single files per database for a couple of reasons:

    1. Makes it easy to rebuild a database using mysql databasename < databasename.sql
    2. If a customer wants a copy of their database I can be certain that they're only getting their own data without having to think about it!
      [/list=1]

      Guess it's horses for courses at the end of the day though :)

      Cheers,

      Garan.
     
  4. dasmo

    dasmo Guest

    0
     
    Thanks! This works great!

    Edit: Except for when I update plesk and it overwrites it :p

    I guess I'll save it somewhere else
     
  5. garan

    garan Guest

    0
     
    Reading through my first post I should have been a little more descriptive about 'taking a copy of the script'. I copied the mysqldump.sh into another place, modified the script and used it from there. My Plesk installation is therefore unchanged.
     
Loading...