PDA

View Full Version : BerksWebGuy's script


Marks_Smoothie
3-7-06, 02:51 PM
I found this script in a sticky topic, but it's been closed so I can't respond to it:

<?
$day = (date("d"));
$filename="/www/u/username/dbbackup_$day.sql";
if( file_exists($filename) ) {
unlink("$filename");
}

system( "/usr/local/bin/mysqldump --opt --no-create-db --user=username --password=user_password --host=mysqlxx.powweb.com database_name > $filename",$result1);
system( "/usr/local/bin/mysql --user=username --password=user_password --host=mysqlxx.powweb.com database_name < $filename",$result2);

$size = filesize("$filename");
$runtime = (bdate(" F d h:ia"));
$message .= "The DB backup and copy has been run.\n\n";
$message .= "The get return code was: $result1\n";
$message .= "The put return code was: $result2\n\n";
$message .= "Size of the backup: $size bytes\n\n";
$message .= "Server time of the backup: $runtime\n\n";
mail("you@yoursite.com", "DB Copy" , $message, "From: Your Site <>");
?>

BerksWebGuy, this was yours to move a database. Seeing as I don't know that much about MySQL, exactly what am I supposed to customise? Because I changed the username, password, database name and powweb host, but it still doesn't work.
It keeps saying I have a wrong format at the top, with the date and filename :confused:
Anything I need to change in there?

mitchind
3-7-06, 02:57 PM
You also have to change the line:$filename="/www/u/username/dbbackup_$day.sql";to use YOUR username and first initial of username

BerksWebGuy
3-7-06, 03:08 PM
Ok...lets say everything in CAPS...you have to edit:

<?
$day = (date("d"));
$filename="/www/U/USERNAME/dbbackup_$day.sql";
if( file_exists($filename) ) {
unlink("$filename");
}

system( "/usr/local/bin/mysqldump --opt --no-create-db --user=MYSQLUSERNAME --password=MYSQLPASSWORD --host=MYSQLXX.powweb.com DATABASE_NAME > $filename",$result1);
system( "/usr/local/bin/mysql --user=MYSQLUSERNAME --password=MYSQLPASSWORD --host=MYSQLXX.powweb.com DATABASE_NAME < $filename",$result2);

$size = filesize("$filename");
$runtime = (date(" F d h:ia"));
$message .= "The DB backup and copy has been run.\n\n";
$message .= "The get return code was: $result1\n";
$message .= "The put return code was: $result2\n\n";
$message .= "Size of the backup: $size bytes\n\n";
$message .= "Server time of the backup: $runtime\n\n";
mail("YOU@YOURSITE.COM", "DB Copy" , $message, "From: YOUR SITE <>");
?>


So thats results in editing the following lines in the above code:

$filename="/www/U/USERNAME/dbbackup_$day.sql";
//
system( "/usr/local/bin/mysqldump --opt --no-create-db --user=MYSQLUSERNAME --password=MYSQLPASSWORD --host=MYSQLXX.powweb.com DATABASE_NAME > $filename",$result1);
system( "/usr/local/bin/mysql --user=MYSQLUSERNAME --password=MYSQLPASSWORD --host=MYSQLXX.powweb.com DATABASE_NAME < $filename",$result2);
//
mail("YOU@YOURSITE.COM", "DB Copy" , $message, "From: YOUR SITE <>");


Added this to the sticky for others that may have the same question.

Marks_Smoothie
3-7-06, 03:15 PM
Still not working.

I keep getting this error:

ERROR: Onbekende Punctuatie String @ 1
STR: <?
SQL: <?
$day = (date("d"));



SQL-query:


MySQL retourneerde:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '<?
$day = (date("d"))' at line 1

I am supposed to run this script as a MySQL query right? Have no idea where else to do it.
Sorry, as I said I'm not an SQL bright light

mitchind
3-7-06, 03:50 PM
It's a php script - not MySQL.

Copy/paste script into text file,
save as a .php file,
ftp file to your htdocs or protected directory
run from browser.

Marks_Smoothie
3-7-06, 04:01 PM
Lol...right.................so didn't figure that out!

Get this error:
Fatal error: Call to undefined function: bdate() in /www/w/westlifebel1/htdocs/databasemove.php on line 12

Prob something I did wrong though.
Don't know what :confused:

extras
3-7-06, 04:19 PM
Probably, you made a typo.
Look at the $day = (date("d")); line, you must have 'b' before date: $day = (bdate("d"));
Remove the 'b'.

Marks_Smoothie
3-7-06, 04:26 PM
Okay, now I'm not getting anything at all so I assume it worked.
My problem is, that when I visit my URL, www.wherewebelong.com I get to my boards.
But the minute I log in, it changes back to www.westlifebelgium.com/board
So basically if I delete the boards there, they'll be gone 'cause they're obviously not set yet at my new URL

extras
3-7-06, 04:34 PM
Oh, that was a typo BWG made in the line bellow .... (I corrected his code).
You should be receiving a mail (if you put mail address correctly).

As for the board setup, i feel that you need to change the configuration.
Deleting wouldn't solve the problem, IMO.

Marks_Smoothie
3-7-06, 04:37 PM
Well then I might aswell setup the whole thing new again.
I wanted to keep everything so my users wouldn't have to re-register.
But I don't know enough about this stuff to configure it right.
Wouldn't know where to begin changing things

extras
3-7-06, 04:42 PM
I think you can import User related tables to avoid re-registering, too.
But you've got to find out what to do for the script you are using.

Marks_Smoothie
3-7-06, 04:44 PM
Well, it's phpbb
There's bound to be something pre-made I can just enter!

extras
3-7-06, 04:51 PM
omegaman66 recovered his thema. maybe he knows how to import Users.
http://forum.powweb.com/showthread.php?t=63127

Ask in the phpBB support forum, too. It should be a FAQ item, IMO.

Good luck.

Marks_Smoothie
3-7-06, 04:53 PM
Thanks a million for your help!
Will do

bdunning
3-8-06, 02:48 PM
In case you get the message "Killed", it probably took too long. This happened to me. I fixed it by moving just one table at a time. You can do that adding table_name after the database_name in that first sqldump line. Hope this helps someone...