473,757 Members | 2,083 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MySQL database backup

Hi All,
I'm looking at using PHP and MySQL for a particular website application.
However, I was a bit concerned that if a PHP script went wrong then it would
be possible to accidentally delete or overwrite large chunks of the data in
the database which presumably would then be lost. What is the usual
procedure for these situations?. Is it possible to back up a database
somehow so that data from a previous time can be retrieved?.

Ta,
Dave

Jul 17 '05 #1
4 2574
On 2005-04-13, Dave Moore <da**********@b aesystems.com> wrote:
I'm looking at using PHP and MySQL for a particular website application.
However, I was a bit concerned that if a PHP script went wrong then it would
be possible to accidentally delete or overwrite large chunks of the data in
the database which presumably would then be lost. What is the usual
procedure for these situations?. Is it possible to back up a database
somehow so that data from a previous time can be retrieved?.


Of course. Read up on mysqldump.

--
Cheers
- Jacob Atzen
Jul 17 '05 #2
>Hi All,
I'm looking at using PHP and MySQL for a particular website application.
However, I was a bit concerned that if a PHP script went wrong then it would
be possible to accidentally delete or overwrite large chunks of the data in
the database which presumably would then be lost. What is the usual
procedure for these situations?. Is it possible to back up a database
somehow so that data from a previous time can be retrieved?.


mysqldump.

If you can access your MySQL database directly from a host you
control (e.g. your desktop), dump it to a file on your desktop.
You do need to install the MySQL client on that machine.
This option may not be available as hosts don't allow it or
you don't want your db accessable remotely.

If you can access your MySQL database from a shell account on
the hosting server, dump it to a file on the hosting server,
then FTP it somewhere else safe (if the hosting server loses
a hard drive, it might lose the master copy AND your backup
if you don't keep a copy elsewhere).

If you have to use PHP to access MySQL, invoke mysqldump from PHP
(exec()) and redirect the output to a file on the hosting server,
then FTP it somewhere else safe.

You restore stuff generated by mysqldump (which is a series of SQL
commands) by feeding the dump into the command line client called 'mysql',
e.g. for UNIX shells:
mysqldump -h host -u user -ppassword --databases db1 db2 ... > mysql.dump

mysql -h host -u user -ppassword db1 < mysql.dump

mysqldump has lots of options. Depending on your hosting situation,
you may want to back up all databases or just the one your host
assigns to you. Or maybe you want just specific tables. You can
back up just the schema (no data) or all of it. Some of the options
(like host name) may default properly in the right circumstances.

Gordon L. Burditt
Jul 17 '05 #3
Dave Moore wrote:
Hi All,
I'm looking at using PHP and MySQL for a particular website application.
However, I was a bit concerned that if a PHP script went wrong then it would
be possible to accidentally delete or overwrite large chunks of the data in
the database which presumably would then be lost. What is the usual
procedure for these situations?. Is it possible to back up a database
somehow so that data from a previous time can be retrieved?.

Ta,
Dave

I've been wondering about a closely related, or perhaps identical,
problem. How can I make a system of nightly backups where I can revert
to any previous nightly backup without gobbling up hard drive space
storing a file for each backup. Something like Subversion or CVS, except
for being more suitable for simple backups. Any products or methods out
there?

Pingveno
Jul 17 '05 #4
Dave Moore wrote:
Hi All,
I'm looking at using PHP and MySQL for a particular website
application.
However, I was a bit concerned that if a PHP script went wrong then it
would be possible to accidentally delete or overwrite large chunks of the
data in the database which presumably would then be lost. What is the
usual procedure for these situations?. Is it possible to back up a
database somehow so that data from a previous time can be retrieved?.

Not a PHP question, not even a MySQL question.

Some people use stored procedures (mysql now supports stored procedures) to
try to isolate the DB from the application but at the end of the day it
doesn't really solve the problem - the only way PHP will be asing the
database to delete lots of stuff is because a combination of your PHP code
and the users request made it so. The real answer is to implement a proper
software engineering model (like CMMS) and write better code.

.....oh and don't forget to do backups.

C.
Jul 17 '05 #5

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

Similar topics

3
15464
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...
4
4425
by: Neil | last post by:
Hi, I hope this question isn't too far off topic....I'm almost at my wits end trying to figure this out. I have a Mysql database and I wish to automate the backup of the database because I don't wish to rely on the web host doing so. I am using the "dbsender.php" script, which is written for this exact purpose (available at hotscripts.com). If I execute the script via my browser, the database is emailed to me in a 'gzip' format, which...
1
1950
by: Konrad | last post by:
I have an internet portal based on MySql database and what I need is to make a database backup , after each actualization of data. I know how should PHP code look like but I have no idea how to create SQL command that will backup full database. I know that this group does't concern MySql directly but lots of PHP programmers have wide knowledge of MySql. I will be grateful for help.
4
12726
by: news | last post by:
Our production database in an exported textfil runs about 60 MB. Compressed that's about 9 MB. I'm trying to import the export into another machine running FC3 and mySQL 11.18, and it appears as though the file may be too big! When I try to do it via command line: mysql -u root --host=localhost printing < ./printing.txt It eventually errors out with a "syntax error on line X" and only about
4
2137
by: wzhao6898 | last post by:
Hi there, I'm trying to figure out if it's going painless to upgrade our oooold mysql 3.23 to the latest MySQL 4 or 5. Any suggestions? Thanks in advance! David
0
1896
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
6
1745
by: frank78 | last post by:
Hi everyone, I am having a little bit of trouble backing up some mySQL tables. I've been trying to adapt a script I found on the internet at http://blogs.linux.ie/xeer/2005/06/28/simple-mysql-backup/ . However, i have been having trouble (under bash) on getting it to work. I know my mysql account has full privileges to all account information. Using the script below, it even prints out all the table names, however, when I run this...
2
1834
by: GS | last post by:
Implemented web application using MySQL to maintain inventory of the office PC's/laptops/Routers/hubs and other stuff, here we are using MySQL as back-end Database on Linux Operating system. I need to backp all these Inventory database into CD/Tape/Floppy, which is the right directory (MySQL database) to backup (incase if the current MySQL server crashes, then I should be able keep copy of my inventory), please let me know, appreciated. We...
7
4196
by: Randy | last post by:
Folks: We have a web-based app that's _really_ slowing down because multiple clients are writing their own private data into a single, central database. I guess the previous programmer did things this way because it made things easy. Well, I'm the person that has to put up with the long-term headache. Anywho, someone at work wants things sped up, so what I'm looking at doing is this for each client:
4
4065
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
9487
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
9297
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,...
1
9884
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
9735
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
8736
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...
0
6556
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
5168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3828
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
3
2697
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.