HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   General (http://www.howtoforge.com/forums/forumdisplay.php?f=25)
-   -   Db's dumps in seperate files? (http://www.howtoforge.com/forums/showthread.php?t=60826)

skoena 5th March 2013 18:57

Db's dumps in seperate files?
 
How to get a dump of all db's in seprate files?

I want to restore all db's on newly installed server.

Can somebody give exact codes to get this done via commandline?

tahunasky 6th March 2013 03:24

this is what i use.

mysqldump dbispconfig -u {MYSQLUSER} -p {MYSQLPASSWORD} > /tmp/dbispconfig.sql

replace {MYSQLUSER} with username and {MYSQLPASSWORD} with password.

Just do the same command for each database.

You can also do a dump/backup and restore from phpmyadmin, which is probably easier.

Parsec 6th March 2013 06:30

Or you could do them all at once if you have the root password for mysql

Code:

#!/bin/bash

cd /var/backup
for i in $(/usr/bin/mysql -uroot -p<your_root_password> -e 'show databases'|grep -v Database);

do
if ( test $i != information_schema )
then
/usr/bin/mysqldump -uroot -p<your_root_password> $i > ./$i.dump ;
fi
done

The just go to /var/backup and grab them (this assumes you have a /var/backup dir - if not change it to something else in the script.


All times are GMT +2. The time now is 08:38.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.