Hi all, I am wanting to automatically do dump of a mysql database nightly
using cron and some kind of script that will email the whole db structure to
me (as an attachment or as plain text in my email) - including the data in
the db. So, if the db was ever lost, I could go to my email, find the dump
and copy and paste it into the mysql db again.
Does anyone know how to do this in PHP or of a premade (and free) script out
there, preferably written in PHP?
Thanks,
Mosher 6 1798
Mosher wrote: Hi all, I am wanting to automatically do dump of a mysql database nightly using cron and some kind of script that will email the whole db structure to me (as an attachment or as plain text in my email) - including the data in the db. So, if the db was ever lost, I could go to my email, find the dump and copy and paste it into the mysql db again.
Does anyone know how to do this in PHP or of a premade (and free) script out there, preferably written in PHP?
Dump it using mysqldump into a text file using one of the system() or
exec() type function calls, then either attach the resulting text file
to your email or make it the body of the message.
--
Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com
Chris Hope <bl*******@elec trictoolbox.com > wrote in news:d593li$i6f $1
@lust.ihug.co.n z: Mosher wrote:
Hi all, I am wanting to automatically do dump of a mysql database nightly using cron and some kind of script that will email the whole db structure to me (as an attachment or as plain text in my email) - including the data in the db. So, if the db was ever lost, I could go to my email, find the dump and copy and paste it into the mysql db again.
Does anyone know how to do this in PHP or of a premade (and free) script out there, preferably written in PHP?
Dump it using mysqldump into a text file using one of the system() or exec() type function calls, then either attach the resulting text file to your email or make it the body of the message.
..... though if your data is really important, perhaps regular e-mail should
be avoided, lest anyone snoop in on it...
Chris Hope wrote: Mosher wrote: Hi all, I am wanting to automatically do dump of a mysql database nightly using cron and some kind of script that will email the whole db structure to me (as an attachment or as plain text in my email) - including the data in the db. So, if the db was ever lost, I could go to my email, find the dump and copy and paste it into the mysql db again.
Does anyone know how to do this in PHP or of a premade (and free) script out there, preferably written in PHP?
Dump it using mysqldump into a text file using one of the system() or exec() type function calls, then either attach the resulting text file to your email or make it the body of the message.
I'm no great Php expert, probably not perfect Php, but here's the
function I use in my script:
////////////////////////////////////////////
function create_db_backu p ($path, $tables = "")
{
$filename=$DBNA ME . "_backup" . "_" . date("n-j-y_H-i-s") .
".sql";
system("mysqldu mp --add-drop-table -u $USRNAME -p $PASSWRD $DBNAME
$tables > $path/$filename", $result);
system ("gzip $path/$filename", $result);
$gzname = $filename . ".gz";
return $gzname;
}
$path is the directory I save backups to.
$tables is optional. If empty, mysqldump will backup all tables,
otherwise it's a list of tables to backup (separated by a space, e.g."
table1 table2 table3" - no quotes).
I use --add-drop-table because it seems like the simplest sql file to
use for a restore.
Finally, I gzip it to make it smaller.
Now all you have to do is mail it to yourself. I use Phpmailer.
--
*************** **************
Chuck Anderson • Boulder, CO http://www.CycleTourist.com
Integrity is obvious.
The lack of it is common.
*************** **************
Good Man wrote: Chris Hope <bl*******@elec trictoolbox.com > wrote in news:d593li$i6f $1 @lust.ihug.co.n z:
Mosher wrote:
Hi all, I am wanting to automatically do dump of a mysql database nightly using cron and some kind of script that will email the whole db structure to me (as an attachment or as plain text in my email) - including the data in the db. So, if the db was ever lost, I could go to my email, find the dump and copy and paste it into the mysql db again.
Does anyone know how to do this in PHP or of a premade (and free) script out there, preferably written in PHP?
Dump it using mysqldump into a text file using one of the system() or exec() type function calls, then either attach the resulting text file to your email or make it the body of the message.
.... though if your data is really important, perhaps regular e-mail should be avoided, lest anyone snoop in on it...
Especially if it contains sensitive data. If you have ssh or sftp access
to the server you can always download the dump file via sftp which
makes it much safer. I manage my own servers and all the databases are
dumped to text files on a daily basis and rsync'd to my local machine
on a daily basis via ssh.
--
Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com
I have a DOS batch file setup with the Windows task scheduler to run a
batch (BAT) file every morning. My script is dynamically created my an
HTA application that rebuilds it every morning (for the dates), but
that is not necessary to run the script. The basic batch scripting is
pretty simple.
--- Begin code ---
"C:\Program Files\MySQL\bin \mysqldump.exe" --databases --all
--allow-keywords --quote-names --flush_logs --host=localhost --opt
--user=root library > "D:\MySQL_Backu ps\2005.01.24 SYSTEM mysql library
backup.sql"
--- End code ---
(Should be all on one continous line)
"--host=" is the name of the computer to connect to.
"--user=" is the login to use in accessing the DB.
Specify the database name after the "--user=root" section where you see
"library" in the line.
The text after ">" at the end is the destination path where the "SQL"
file is to be deposited.
The resulting text file is nothing more that a really big MySQL query
that rebuilds the databases, indexes, data, etc. I use the "SQLyog"
application v3.02 ("http://www.webyog.com" ) to restore the files. It
has an "Execute Batch Script" feature that reads in the SQL file and
processes it back into the database. I have to create the empty
database first, then restoring it is a piece of cake. I use this
technique to copy databases to my development system at home to work on
stuff. So far it works pretty good, and if you ZIP the file it
compresses really nicely.
Daniel
Thanks for the help all - I'll try what you mentioned.
Mosher
"Chuck Anderson" <we************ @seemy.sig> wrote in message
news:xt******** ************@co mcast.com... Chris Hope wrote:
Mosher wrote:
Hi all, I am wanting to automatically do dump of a mysql database nightly using cron and some kind of script that will email the whole db structure to me (as an attachment or as plain text in my email) - including the data in the db. So, if the db was ever lost, I could go to my email, find the dump and copy and paste it into the mysql db again.
Does anyone know how to do this in PHP or of a premade (and free) script out there, preferably written in PHP?
Dump it using mysqldump into a text file using one of the system() or exec() type function calls, then either attach the resulting text file to your email or make it the body of the message.
I'm no great Php expert, probably not perfect Php, but here's the function I use in my script:
//////////////////////////////////////////// function create_db_backu p ($path, $tables = "") { $filename=$DBNA ME . "_backup" . "_" . date("n-j-y_H-i-s") . ".sql";
system("mysqldu mp --add-drop-table -u $USRNAME -p $PASSWRD $DBNAME $tables > $path/$filename", $result);
system ("gzip $path/$filename", $result);
$gzname = $filename . ".gz";
return $gzname; }
$path is the directory I save backups to.
$tables is optional. If empty, mysqldump will backup all tables, otherwise it's a list of tables to backup (separated by a space, e.g." table1 table2 table3" - no quotes).
I use --add-drop-table because it seems like the simplest sql file to use for a restore.
Finally, I gzip it to make it smaller.
Now all you have to do is mail it to yourself. I use Phpmailer.
-- *************** ************** Chuck Anderson • Boulder, CO http://www.CycleTourist.com Integrity is obvious. The lack of it is common. *************** ************** This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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...
|
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.
|
by: Duane Winner |
last post by:
Hello all -
I'm having a small problem with the mysql startup script that ships with
MySQL-3.23.56-1.
I'm running on RedHat Linux.
It works fine, but I have a backup server that runs a script that passes
these commands remotely through ssh:
(1) ssh dbsys-dc "sudo /etc/init.d/mysql stop" (2) ssh dbsys-dc "sudo tar
|
by: John Smith |
last post by:
Hi
I am currently reviewing our backup procedures. Part of the issue has been
finding the right fit. There are obviously backup products that provide
mysql agents but unfortunately can not for fill our complete backup/disaster
requirements. I have evaluated bakbone, arkeia, brightstor, veritas. I am
currently looking at evault, commvault and ipstor.
I am now looking to separate mysql from the rest of the backup. I am
looking to...
| |
by: Astra |
last post by:
Hi All
I understand that the basic principles to create a TCP/IP backup program for
a remote MySQL DB are:
a) Query/retrieve the schema.
b) Query/retrieve each table and create inserts for each row of data.
|
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
|
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
|
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...
|
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.
|
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...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |