Re: [PHP] MySQL Dump

2004-04-24 Thread Michal Migurski
> I just tested it and yes, the Michal function runs on Windows and Linux.
> Just must write the path in the proper format for the OS you're using.

Holy smokes, that's good news. :)  Spreading dis-information is my price
for not having the first clue about windows.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] MySQL Dump

2004-04-24 Thread Jordi Canals
I just tested it and yes, the Michal function runs on Windows and Linux. 
Just must write the path in the proper format for the OS you're using.

Regards,
Jordi.
Matt Palermo wrote:

Will this work on both a Windows and Unix server?

"Michal Migurski" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Is there an easy way to do a mysql dump routine written in php?  I
basically want to write a function to backup a database and have it
create all the neccessary structures and data in the dump.  I know
phpMyAdmin will do this for me, but I want to write a function to do
this incase the server doesn't have phpMyAdmin installed.  Any ideas?
Why not use the existing mysqldump command-line utility?

function mysql_dump($db, $user, $pass)
{
return shell_exec("/path/to/mysqldump
  --user={$user} --password={$pass}
  --complete-insert --add-drop-table
   {$db}");
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] MySQL Dump

2004-04-23 Thread Michal Migurski
> Will this work on both a Windows and Unix server?

No, it's most assuredly a unix-only thing.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] MySQL Dump

2004-04-23 Thread Matt Palermo
Will this work on both a Windows and Unix server?


"Michal Migurski" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> > Is there an easy way to do a mysql dump routine written in php?  I
> > basically want to write a function to backup a database and have it
> > create all the neccessary structures and data in the dump.  I know
> > phpMyAdmin will do this for me, but I want to write a function to do
> > this incase the server doesn't have phpMyAdmin installed.  Any ideas?
>
> Why not use the existing mysqldump command-line utility?
>
> function mysql_dump($db, $user, $pass)
> {
> return shell_exec("/path/to/mysqldump
>--user={$user} --password={$pass}
>--complete-insert --add-drop-table
> {$db}");
> }
>
> Or, skip PHP entirely and place a call to mysqldump with a suitable
> select-privilege-only username & password in a cron job, if you're on a
> unix machine. I use the following shellscript to do periodic backups to
> RCS repositories in /usr/local/var/backups:
>
> #!/bin/sh
>
> if [ $# -ne 3 ]; then
> echo 'Usage:';
> echo ' mysql-backup.sh   ';
> exit;
> fi;
>
> USER=$1;
> PASS=$2;
> DB=$3;
> MYSQLDUMP=/usr/local/bin/mysqldump;
>
> BACKUP_DIR=/usr/local/var/backups;
> SQL_FILE=$DB.mysql;
> RCS_FILE=$SQL_FILE,v;
>
> cd $BACKUP_DIR;
>
$MYSQLDUMP --user=$USER --password=$PASS --complete-insert --add-drop-table
$DB > $SQL_FILE;
>
>  the remaining lines can be ommitted if RCS isn't needed 
>
> if [ ! -f $RCS_FILE ]; then
> echo "import" | rcs -q -i $SQL_FILE;
> else
> rcs -q -l $RCS_FILE;
> fi;
>
> echo "mysql_backup.sh" | ci -q $SQL_FILE;
>
> -
> michal migurski- contact info and pgp key:
> sf/cahttp://mike.teczno.com/contact.html

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] MySQL Dump

2004-04-22 Thread Michal Migurski
> Is there an easy way to do a mysql dump routine written in php?  I
> basically want to write a function to backup a database and have it
> create all the neccessary structures and data in the dump.  I know
> phpMyAdmin will do this for me, but I want to write a function to do
> this incase the server doesn't have phpMyAdmin installed.  Any ideas?

Why not use the existing mysqldump command-line utility?

function mysql_dump($db, $user, $pass)
{
return shell_exec("/path/to/mysqldump
--user={$user} --password={$pass}
--complete-insert --add-drop-table
{$db}");
}

Or, skip PHP entirely and place a call to mysqldump with a suitable
select-privilege-only username & password in a cron job, if you're on a
unix machine. I use the following shellscript to do periodic backups to
RCS repositories in /usr/local/var/backups:

#!/bin/sh

if [ $# -ne 3 ]; then
echo 'Usage:';
echo '  mysql-backup.sh   ';
exit;
fi;

USER=$1;
PASS=$2;
DB=$3;
MYSQLDUMP=/usr/local/bin/mysqldump;

BACKUP_DIR=/usr/local/var/backups;
SQL_FILE=$DB.mysql;
RCS_FILE=$SQL_FILE,v;

cd $BACKUP_DIR;
$MYSQLDUMP --user=$USER --password=$PASS --complete-insert --add-drop-table $DB > 
$SQL_FILE;

 the remaining lines can be ommitted if RCS isn't needed 

if [ ! -f $RCS_FILE ]; then
echo "import" | rcs -q -i $SQL_FILE;
else
rcs -q -l $RCS_FILE;
fi;

echo "mysql_backup.sh" | ci -q $SQL_FILE;

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] MySQL Dump

2004-04-22 Thread Matt Palermo
Is there an easy way to do a mysql dump routine written in php?  I basically
want to write a function to backup a database and have it create all the
neccessary structures and data in the dump.  I know phpMyAdmin will do this
for me, but I want to write a function to do this incase the server doesn't
have phpMyAdmin installed.  Any ideas?

Thanks,

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] MySQL Dump using PHP

2003-12-07 Thread Cesar Aracena

"Justin Patrin" <[EMAIL PROTECTED]> wrote
news:[EMAIL PROTECTED]

> Use mysqldump in a system() call, redirect it to a temp file, then read
> it back and out to the browser.
>
> Or, you could use popen to get the output piped back into php. Make sure
> to check the mysqldump options for things you need (I often use -Q -e
> --add-drop-table).
>
>  header('Content-type: application/mysql');
> header('Content-disposition: attachment; filename=dump.sql');
> $fd = popen('mysqldump -uuser -ppassword databaseName', 'r');
> while(!feof($fd)) {
>echo fgets($fd);
> }
> pclose($fd);
> ?>

Thanks a lot. I haven't used this functions ever, but I'm sure PHP.net (and
maybe some help from you guys) will do the job. Also thanks to Ajai for the
idea.
___
Cesar L. Aracena
Commercial Manager / Developer
ICAAM Web Solutions
2K GROUP
Neuquen, Argentina
Tel: +54.299.4774532
Cel: +54.299.6356688
E-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] MySQL Dump using PHP

2003-12-06 Thread Justin Patrin
Cesar Aracena wrote:

The thing is that I don't have phisical access to the server and it doesn't
have telnet access either. What I want to achieve is to make a password
protected page inside my site were a button is kept to start a full backup
of my MySQL DB and after clicking on it, be able to select the Internet
Explorer's option to store the file xxx.sql in my HDD. Is this possible?
I use the built'in function of phpbb that does exactly that and it's just
beautifull.
Thanks again,
___
Cesar L. Aracena
Commercial Manager / Developer
ICAAM Web Solutions
2K GROUP
Neuquen, Argentina
Tel: +54.299.4774532
Cel: +54.299.6356688
E-mail: [EMAIL PROTECTED]
"Ajai Khattri" <[EMAIL PROTECTED]> escribió en el mensaje
news:[EMAIL PROTECTED]
On Sat, Dec 06, 2003 at 04:39:22PM -0300, Cesar Aracena wrote:


I am wondering if someone could point me to the right functions to use
to

make a script to dump all the tables in a specific MySQL DB. I need this
to

keep a daily backup from my site as the hackers are screwing up my site
very

often these days.
Much easier to use mysqldump in a shell script to do this.

man mysqldump

--
Aj.
Sys. Admin / Developer
Use mysqldump in a system() call, redirect it to a temp file, then read 
it back and out to the browser.

Or, you could use popen to get the output piped back into php. Make sure 
to check the mysqldump options for things you need (I often use -Q -e 
--add-drop-table).


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] MySQL Dump using PHP

2003-12-06 Thread Ajai Khattri
On Sat, Dec 06, 2003 at 06:02:40PM -0300, Cesar Aracena wrote:

> The thing is that I don't have phisical access to the server and it doesn't
> have telnet access either. What I want to achieve is to make a password
> protected page inside my site were a button is kept to start a full backup
> of my MySQL DB and after clicking on it, be able to select the Internet
> Explorer's option to store the file xxx.sql in my HDD. Is this possible?
> I use the built'in function of phpbb that does exactly that and it's just
> beautifull.

Of course it is possible to do it that way (in which case, you can probably
look at how phpBB does it).

The only problem with this is if the script takes too long to execute (rare,
but possible) in which case your browser could timeout.

-- 
Aj.
Sys. Admin / Developer

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] MySQL Dump using PHP

2003-12-06 Thread Cesar Aracena
The thing is that I don't have phisical access to the server and it doesn't
have telnet access either. What I want to achieve is to make a password
protected page inside my site were a button is kept to start a full backup
of my MySQL DB and after clicking on it, be able to select the Internet
Explorer's option to store the file xxx.sql in my HDD. Is this possible?
I use the built'in function of phpbb that does exactly that and it's just
beautifull.

Thanks again,
___
Cesar L. Aracena
Commercial Manager / Developer
ICAAM Web Solutions
2K GROUP
Neuquen, Argentina
Tel: +54.299.4774532
Cel: +54.299.6356688
E-mail: [EMAIL PROTECTED]

"Ajai Khattri" <[EMAIL PROTECTED]> escribió en el mensaje
news:[EMAIL PROTECTED]
> On Sat, Dec 06, 2003 at 04:39:22PM -0300, Cesar Aracena wrote:
>
> > I am wondering if someone could point me to the right functions to use
to
> > make a script to dump all the tables in a specific MySQL DB. I need this
to
> > keep a daily backup from my site as the hackers are screwing up my site
very
> > often these days.
>
> Much easier to use mysqldump in a shell script to do this.
>
> man mysqldump
>
> --
> Aj.
> Sys. Admin / Developer

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] MySQL Dump using PHP

2003-12-06 Thread Ajai Khattri
On Sat, Dec 06, 2003 at 04:39:22PM -0300, Cesar Aracena wrote:

> I am wondering if someone could point me to the right functions to use to
> make a script to dump all the tables in a specific MySQL DB. I need this to
> keep a daily backup from my site as the hackers are screwing up my site very
> often these days.

Much easier to use mysqldump in a shell script to do this.

man mysqldump

-- 
Aj.
Sys. Admin / Developer

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] MySQL Dump using PHP

2003-12-06 Thread Cesar Aracena
Hi all,

I am wondering if someone could point me to the right functions to use to
make a script to dump all the tables in a specific MySQL DB. I need this to
keep a daily backup from my site as the hackers are screwing up my site very
often these days.

Thanks in advanced,
___
Cesar L. Aracena
Commercial Manager / Developer
ICAAM Web Solutions
2K GROUP
Neuquen, Argentina
Tel: +54.299.4774532
Cel: +54.299.6356688
E-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] mysql dump --> via php

2002-06-10 Thread Jason Wong

On Monday 10 June 2002 16:34, Wilbert Enserink wrote:
> Hi all,
>
>
> I have a .txt file containing a mysql dump. Normally when I would restore
> this dump I would go to the mysql 'prompt' and type something like: mysql <
> dimpfile.txt. I would use SSH or telnet for this.
>
>
> Now I have this new problem: I cannot reach the sql pompt via SSH/telnet.
> Is there any other way to create all the tables and records from the
> dumpfile.txt into the database on the database server??
>
> Maybe it is possible to copy paste the sql statements into a php file which
> can do this? I can then upload this php file to the webserver and perform
> the job. Maybe anybody can advise me on the php code part of this solution.

The easiest solution is to install phpMyAdmin.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
Doing gets it done.
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] mysql dump --> via php

2002-06-10 Thread Wilbert Enserink

Hi all,


I have a .txt file containing a mysql dump. Normally when I would restore this dump I 
would go to the mysql 'prompt' and type something like: mysql < dimpfile.txt. I would 
use SSH or telnet for this.


Now I have this new problem: I cannot reach the sql pompt via SSH/telnet. Is there any 
other way to create all the tables and records from the dumpfile.txt into the database 
on the database server??

Maybe it is possible to copy paste the sql statements into a php file which can do 
this?
I can then upload this php file to the webserver and perform the job.
Maybe anybody can advise me on the php code part of this solution.

Regards,


thx Wilbert Enserink

-
Pas de Deux
Van Mierisstraat 25
2526 NM Den Haag
tel 070 4450855
fax 070 4450852
http://www.pdd.nl
[EMAIL PROTECTED]
-


Re: [PHP] MySQL Dump In PHP

2001-06-22 Thread Aral Balkan

I use the mysqldump command line utility to do this and I don't know how to
interface that from PHP. However:

I just checked how phpMyAdmin does it and apparently it has functions that
re-create the dump using queries. You might want to download it
(http://www.phpwizard.net/projects/phpMyAdmin/) and check out the files
db_dump.php, tbl_dump.php and db_readdump.php.

Hope this helps!

Aral :)



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] MySQL Dump In PHP

2001-06-22 Thread Chadwick, Russell



 
mysqldump is a command to be used at a prompt, from php 
you could 
system 
("mysqldump whatever > /tmp/dump.sql");

---
Toolshed Computer Productions - Professional PHP Hosting
Hosting - Dedicated Servers - Design - Programming
http://www.toolshed51.com

  -Original Message-From: Chris Anderson 
  [mailto:[EMAIL PROTECTED]]Sent: Friday, June 22, 2001 1:16 
  AMTo: [EMAIL PROTECTED]Subject: [PHP] MySQL Dump 
  In PHP
  I've been reading through the MySQL manual about 
  backing up my database using mysql dump. I tried passing it as a Query in PHP 
  but that doesn't seem to work. Does anyone know how to do this? Also does the 
  dump back up the files into a directory I specify? I am on a virtual host and 
  need to create the files in my own directories. Any help would be 
  appreciated


[PHP] MySQL Dump In PHP

2001-06-22 Thread Chris Anderson



I've been reading through the MySQL manual about 
backing up my database using mysql dump. I tried passing it as a Query in PHP 
but that doesn't seem to work. Does anyone know how to do this? Also does the 
dump back up the files into a directory I specify? I am on a virtual host and 
need to create the files in my own directories. Any help would be 
appreciated