Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am making script to backup users home directories and databases. i can make backup by going through dirs but i am not able to find a way to gets databases belong to particular user

share|improve this question

migrated from stackoverflow.com May 23 '11 at 1:05

This question came from our site for professional and enthusiast programmers.

1  
Databases don't belong to users in MySQL. –  Ignacio Vazquez-Abrams May 21 '11 at 15:45
    
Are you talking about Linux users or MySQL users? Are you backing up in SQL format or hot-copying the database dirs? –  Benjamin Morel May 21 '11 at 15:46
1  
Are the database usernames the same as the home directories? –  mhitza May 21 '11 at 15:48
    
yes db users same as home dirs and DB names start with username_something –  Mirror51 May 21 '11 at 15:53
add comment

1 Answer

up vote 1 down vote accepted

If you plan to use mysqldump, which doesn't support wildcards in database names AFAIK, you could first from your Python script issue a SHOW DATABASES query, which will return all database names.

Then group them by user name, and call mysqldump with the --databases option based on the result of your script.

There may be simpler, turnkey solutions however.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.