tar corrupts my sql file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
php_ghost
Forum Commoner
Posts: 55
Joined: Thu Jan 11, 2007 3:29 am

tar corrupts my sql file

Post by php_ghost »

I backed up my database using this code:

Code: Select all

       
exec("mysqldump --opt --host=$db_host --user=$db_user --password=$db_pass '$db_name' > $filename.sql");
exec("tar czvf $filename.tar.gz $filename.sql");
 
now I'm trying to restore my database by uploading the file and then run this code

Code: Select all

 
exec("tar -zxvf $filename", $file);
exec("mysql --verbose --user=$db_user --password=$db_pass $db_name < ".$db_name."-db-globackup.sql", $result, $response);
 
now my sql file is extracted successfully but the content has lots of special characters, words misspelled etc.

what could be the problem with my script?
TIA
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: tar corrupts my sql file

Post by Benjamin »

Can you post an example of a before and after data result.
Post Reply