473,406 Members | 2,345 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How do I restore a backup in mysql?

I successfully take backups of my database with this php code:

$command = "mysqldump --opt -h$dbhost -u$dbuser -p$dbpass $dbname |
gzip $backupfile.gz";

$dummy = system($command, $retval);

But I can not find the code for restoring a backup file. How is it
done?

Kind regards,

Jan Nordgreen
Jun 2 '08 #1
5 1711
On May 12, 5:22*pm, damezumari <jannordgr...@gmail.comwrote:
I successfully take backups of my database with this php code:

$command = "mysqldump --opt -h$dbhost -u$dbuser -p$dbpass $dbname |
gzip $backupfile.gz";

$dummy = system($command, $retval);

But I can not find the code for restoring a backup file. How is it
done?

just copy the content in that backup file and paste it in mysql
console thats all.
or do this
$mysql -u username -p database < path/to/backup.sql

you have to do google search before you ask anything in mailing list .
Jun 2 '08 #2
I want to restore a .gz file not a .sql file.

I have tried:

$command = "mysql -u$dbuser -p$dbpass $dbname < $backupfile.gz";
$dummy = system($command, $retval);

($dummy === false) returns false and retval returns 1, but the
database is not restored.

What am I doing wrong?

Kind regards,

Jan Nordgreen
Jun 2 '08 #3
On Tue, 13 May 2008 08:27:36 -0700, damezumari wrote:
I want to restore a .gz file not a .sql file.

I have tried:

$command = "mysql -u$dbuser -p$dbpass $dbname < $backupfile.gz"; $dummy
= system($command, $retval);

($dummy === false) returns false and retval returns 1, but the database
is not restored.

What am I doing wrong?

Kind regards,
The .qz file is a compressed tar file.

tar xvfz <your file>.gz

Into a working directory and then perform the restore you with the plain
text file.

--
"Remain calm, we're here to protect you!"

Jun 2 '08 #4
damezumari escribió:
$command = "mysql -u$dbuser -p$dbpass $dbname < $backupfile.gz";
If OS is Unix, try:

$command = "gunzip --to-stdout $backupfile.gz | mysql -u$dbuser
-p$dbpass $dbname";

--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
Jun 2 '08 #5
Alvaro, thank you! It worked like a dream. My server is running Linux.

Kind regards,

Jan Nordgreen
Jun 2 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: James | last post by:
HI, I'm looking for a script that will allow users/admins to have a one click backup solution for a MYSQL Database.. 'BACK DATABASE' button, click and its done... The a restore option, that...
1
by: Jerry T | last post by:
How can I backup and restore a MySQL DB WITHOUT USING EXEC() MYSQL MYSQLDUMP ?? If I try running exec() and mysqldump, I get Fork warning errors ..
2
by: Thomas Bartkus | last post by:
Is it safe to say that restoring the directory from a backup would that restore all database data and structure? All usr/pwd and GRANT info? Thomas Bartkus
3
by: Reuben Pearse | last post by:
Hi all, I've just converted the tables in a big database (approx 27 million records) from MyISAM to InnoDB. When I was using MyISAM I backed up the database by stopping MySQL and then copying...
0
by: xo55ox | last post by:
Hi, I have been trying to set up an automated restore process from prod to backup server. First, I schedule the full database backup nightly, transfer the backup file and restore it to the...
4
by: Hardy | last post by:
hi gurus, now I have to backup and restore a 8 T size db2 database. from two s85 to two 670. the partitions,tablespaces of the db should be redesigned then I plan to use redirected restore. but...
5
by: HSP | last post by:
hi. i need to restore an old database. The db was backed up using a DLT drive, using 2 volumes. The content for the tapes was copied to file onto Solaris machine using rsh and dd (for backup...
0
by: newman | last post by:
Dear all, I have mysql 4.1.11 on my current server, i need my database restore another server.. (another server mysql version is 4.1.11 same.) And now... I just created new my database to new...
0
by: richlittle | last post by:
I am using mysql administrator to perform scheduled daily backups of my employee database. What guarantee do I have after doing a restore that everything has restored correctly? My boss want...
4
by: Bootstrap Bill | last post by:
I'm looking for a PHP program to backup and restore a mysql database. I'm using Godaddy to host a forum. Their mysql control panel will only restore a database of two megabytes or less. My...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.