← Desenvolvimento

backup Mysql!!

Lida 1994 vezes

Offline

kingless 
Membro
Mensagens 857 Gostos 0
Troféus totais: 27
Trófeus: (Ver todos)
Super Combination Combination Topic Starter Poll Voter Poll Starter Level 5 Level 4 Level 3 Level 2 Level 1

Alguem sabe como se faz o backup dos dados do banco de dados da MySQL utilizando um funcao do PHP?
Offline

kingless 
Membro
Mensagens 857 Gostos 0
Troféus totais: 27
Trófeus: (Ver todos)
Super Combination Combination Topic Starter Poll Voter Poll Starter Level 5 Level 4 Level 3 Level 2 Level 1

Ja encontrei, espero que isto tambem ajude quem quer fazer backup do banco de dados:

Código: [Seleccione]

                <?
                $host = "localhost";
                $user = "root";
                $senha = "senha";
                $db = "teste";
                $dbc = mysql_connect($host,$user,$senha);
                $m   = mysql_select_db("$db", $dbc);
                $sql = "show databases";
                $sts = mysql_query($sql,$dbc) or die (mysql_error());
                $data = date("d-m-y");
                while ($row = mysql_fetch_array($sts)){
                $nome = $row[0];
                $NARQUIVO = $nome."-".$data;
                $resp = `mysqldump --host=$host --user=$user --password=$senha  
                   --all-databases > $NARQUIVO.sql` ;
                }
                $arquivo = "mysql_".$data;
                $resp = `tar -cvzf $arquivo.tar.gz *.sql`;
                $resp = `rm *.sql`;
                ?>


Cumps
Offline

cenourinha 
Elite
Mensagens 4094 Gostos 21
Troféus totais: 34
Trófeus: (Ver todos)
Mobile User Apple User Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4

Bastante util! :D
Offline

asturmas 
Administrador
Mensagens 19734 Gostos 50
Feedback +2

Troféus totais: 39
Trófeus: (Ver todos)
Mobile User Windows User Super Combination Combination Topic Starter 100 Poll Votes 50 Poll Votes 10 Poll Votes Poll Voter Poll Starter

Isso fax o backup pra onde?
Guarda num arkivo sql dentro do servidor?
Offline

kingless 
Membro
Mensagens 857 Gostos 0
Troféus totais: 27
Trófeus: (Ver todos)
Super Combination Combination Topic Starter Poll Voter Poll Starter Level 5 Level 4 Level 3 Level 2 Level 1

guarda todos arquivos .sql em  " mysql_data.tar.gz"
Offline

asturmas 
Administrador
Mensagens 19734 Gostos 50
Feedback +2

Troféus totais: 39
Trófeus: (Ver todos)
Mobile User Windows User Super Combination Combination Topic Starter 100 Poll Votes 50 Poll Votes 10 Poll Votes Poll Voter Poll Starter

Vai sempre faxendo o backup ou so kuando se excuta esse ficheiro?
Offline

kingless 
Membro
Mensagens 857 Gostos 0
Troféus totais: 27
Trófeus: (Ver todos)
Super Combination Combination Topic Starter Poll Voter Poll Starter Level 5 Level 4 Level 3 Level 2 Level 1

So quando se executa.
Offline

asturmas 
Administrador
Mensagens 19734 Gostos 50
Feedback +2

Troféus totais: 39
Trófeus: (Ver todos)
Mobile User Windows User Super Combination Combination Topic Starter 100 Poll Votes 50 Poll Votes 10 Poll Votes Poll Voter Poll Starter

ok