473,657 Members | 2,405 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1723
On May 12, 5:22*pm, damezumari <jannordgr...@g mail.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
15460
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 shows all current backups, and restores the selected one with one click...
1
6234
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
2230
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
11406
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 the MYI, MYD, frm files in the database directory, and restored the database in the same way. Is there a similar way to backup and restore InnoDB tables, or do I have to use the InnoDB Hot Backup tool?
0
2076
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 database on the backup server. Meanwhile, I leave the database ready to accept transaction log from the transaction log backup at noon daily. And I had used different restore options to test out the transaction that was being applied. And I couldn't...
4
3801
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 my concern is, such big size db, I'm afraid something unexpected will destory all the effort. Who have related experience? Can you give some advice? Thanks in advance:)
5
3230
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 purposes). Now, the drive is defective and can't read the tapes anymore. Server is AIX 4.3.2 and database is IBM DB2 Server (DB2 for AIX Version 2.1.2)
0
1890
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 server following command: CREATE DATABASE dbname DEFAULT CHARACTER SET latin5 COLLATE
0
1187
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 wants a log of the number of employees in the database to be created at backup time (eg: 4388). Then after restore we should manually check that the number of employees in the database is the same (= 4388) to give us confidence that everything is...
4
4061
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 database is over 13 megabytes in size.
0
8420
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8324
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8842
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7353
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
2743
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1733
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.