473,597 Members | 2,375 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 1718
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
15457
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
6230
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
2227
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
11398
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
2069
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
3799
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
3224
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
1889
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
1184
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
4059
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
7883
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
8263
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...
1
8021
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6677
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
5842
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...
0
5421
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3917
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1492
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1226
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.