views:

23

answers:

1

I have the shell script which first goes in home directory and backups all folders like

OCT-13-2010/username/homebck.tar.gz

and i also backups the database ,ef if i am in user1 folder then all my databases are like username_web

and i use the following to backup

mysqldump --skip-lock-tables -u sqluser -ppassword --skip-extended-insert ${FOLDERNAME}_web | gzip > /backups/mysql/${date2}/DBF_${date1}_${FOLDERNAME}.sql.gz" - ${FOLDERNAME}

This is working fine but the problem is here the name of database has to be username_web

because when i am in the script then there is no way for me to find the databases of user1 and then backup those.

Is there any way because i want to put separate databases in separate folders

+1  A: 

how do you define 'the databases of user1'?

if it's all databases named after the user, you could do something like:

for db in $(mysql -h 127.0.0.1 -e "select schema_name from information_schema.schemata where schema_name like '$username\\_%';"); do
  mysqldump $db ........
done
Javier
thanks buddy i will try that
Mirage