473,237 Members | 1,392 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,237 software developers and data experts.

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 2547
On 2005-04-13, Dave Moore <da**********@baesystems.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
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...
4
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...
1
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...
4
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...
4
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
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...
6
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...
2
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...
7
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...
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: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.