Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: DFarish on November 12, 2009, 05:14:39 PM

Title: Database Backup
Post by: DFarish on November 12, 2009, 05:14:39 PM
I noticed when I upgraded that the Databases were backed up. Is it possable to restore the forum to what I had before i started having all the problems? If so where is the backup file located?

Thank You for all the help.

Doug
Title: Re: Database Backup
Post by: babjusi on November 12, 2009, 05:23:57 PM
Quote from: DFarish on November 12, 2009, 05:14:39 PM
I noticed when I upgraded that the Databases were backed up. Is it possable to restore the forum to what I had before i started having all the problems? If so where is the backup file located?

Thank You for all the help.

Doug

Do you mean the backup made by the upgrader? if so, check your db for tables starting with the backup_ prefix. Those are the tables you need.
Title: Re: Database Backup
Post by: DFarish on November 12, 2009, 05:26:45 PM
Okay. Is there a way for the forum software to restore them? If not how would I do that? I'm real new to PHP and MySQL.

Doug
Title: Re: Database Backup
Post by: babjusi on November 12, 2009, 05:29:09 PM
Quote from: DFarish on November 12, 2009, 05:26:45 PM
Okay. Is there a way for the forum software to restore them? If not how would I do that? I'm real new to PHP and MySQL.

Doug

From which version did you upgrade? All you have to do is upload the files of the version you had before you did the upgrade, then open the Settings.php file and change the db prefix in there to the backup_ whatever name the upgrader gave the tables when it backed them up and you should be all set.
Title: Re: Database Backup
Post by: Norv on November 12, 2009, 05:46:26 PM
First, please make sure you restore the same version of the SMF files as your database is. For that, the large upgrade package to that SMF version is the best choice. Please upload all files in it over those of the version you want to get rid of, if you didn't already.

Option 1:
Perhaps the quickest way to do it is to set your forum to use them, instead of using the current ones. (though it will be useful to keep it in mind for the future, that your tables prefix will become "backup_[previous_prefix]" where previous_prefix is the prefix your tables have now).
Then, upload the file repair_settings.php ( What is repair_settings.php? (http://docs.simplemachines.org/index.php?topic=663.0) ) to your forum directory, then run it from the browser. You will see a page with various settings, including database prefix: change it to backup_[your_previous_prefix] (for instance, if the previous prefix was "smf_" then change it to "backup_smf_".

Option 2:
Perhaps not the quickest, but nicest on the long run: in phpMyAdmin, select your database, and then the "Export" tab. Select the tables starting with backup_ there, and save them all to a file. (with structure too, and data). Then, try opening the resulted sql file in a text editor (a lightweight editor like Notepad++ would be good if you're on windows), and find and replace all occurrences of "backup_" in the name of tables with an empty text.
Save it, then choose to "import" it into another database (that you may need to create). Then, use the same repair_settings.php to correct the name of the database (this time, as it's the database which will be different), or, rename the old database as something else "backup_database" for example, and the new one like the old one (then you don't need to run repair_settings anymore).

ETA: babjusi was much quicker :)
Title: Re: Database Backup
Post by: DFarish on November 12, 2009, 06:03:29 PM
I think that I will do the latter. Running repair_settings.php is what got me in this mess. It changed something that will not let the board talk to the server even though the settings are correct. I may see if I can get my hosting service to move the files for me so I wont mess it up again.

Thank You. Can I leave this open until I see if this is going to work?

Doug
Title: Re: Database Backup
Post by: Norv on November 12, 2009, 06:10:23 PM
Quote from: DFarish on November 12, 2009, 06:03:29 PM
I think that I will do the latter. Running repair_settings.php is what got me in this mess. It changed something that will not let the board talk to the server even though the settings are correct.
This sounds really strange, repair_settings doesn't change anything else but what you see there on its page. If what it's there on the page is correct, then the problem is elsewhere. Was your host's server working correctly at the time?

Of course you can leave topics open for as long as necessary since they're unsolved.
Title: Re: Database Backup
Post by: DFarish on November 12, 2009, 06:32:27 PM
Yes. Right after I ran the php file is when the error in connecting to the server started. If I remember right the repair_settings.php told me on the server name was localhost. That was not right. I found that out in the settings.php file. I made the changes as to what the back up said. and checked with my hosting company and there database techs look over all the settings and said that they all okay. everything matched right down to the last part of the syntax.

This just floored me. I was on the phone at 3:30am for about 45 minutes. Up all night trying to get this resolved.

Anyway if I can leave this open until this is resolved that would be great.

Doug
Title: Re: Database Backup
Post by: Norv on November 13, 2009, 03:01:09 AM
Quote from: DFarish on November 12, 2009, 06:32:27 PM
Yes. Right after I ran the php file is when the error in connecting to the server started. If I remember right the repair_settings.php told me on the server name was localhost. That was not right.
I'm afraid there's a misunderstanding here.
repair_settings does not tell you what to set, it allows you to set the values you know to be appropriate for your system, while it recommends the most likely values. Your host's database server name should be known to you, it is usually "localhost", but if your host's database server name is different, then you should enter your host's value. There is no way to know automatically what you host has decided that your database server is. "localhost" is only a fallback choice, a default choice if your host doesn't use another.
Similar for all the other settings. For example, usually the "attachments" directory is in SMF_folder/attachments, and that is the default value too, of a SMF installation. But if you changed it or want to change it, then you should enter the other value you wish.
What repair_settings does, is to make sure it sets all these values you want and know to be appropriate for your installation, in all the right places in SMF where they should be saved. In other words, it's a convenience tool (it's provided to allow you to change easily those values, instead of searching directly each place in SMF where they are saved), not a tool that can tell you what to do.
Title: Re: Database Backup
Post by: DFarish on November 13, 2009, 10:01:59 AM
Okay I understand that. In your opinion will moving the old database from the old forum to the new restore what I had? The new board is working fine. All the settings are correct and SMF is connecting to the server. I have looked at the old database and all my member records and all the rest are there. I have not made any changes to any thing at all.

Thanks,

Doug
Title: Re: Database Backup
Post by: DFarish on November 14, 2009, 12:08:00 AM
Got the Forum back. Yea!!!!!!!! It was a password issue on the server. All fixed and did not loose anything.

Thanks for all the great help,

Doug
Title: Re: Database Backup
Post by: Norv on November 14, 2009, 06:48:20 AM
Cheers! :)

All that's needed is to have the same database version as the forum files (i.e., if you restored a database from SMF 2.0 RC1.2, then it works with files from SMF 2.0 RC1.2 package, or if you upgraded to RC2, then the RC2 files and a database upgraded to RC2 are needed to work together).
Title: Re: Database Backup
Post by: CerebralJam on November 14, 2009, 04:44:05 PM
Hi there, I have followed this thread with interest.  I did upgrade successfully to RC2 but as 75% of my mods do not have upgrades as yet I decided I needed to go back... I am just struggling with the database connection, even using the repair tool.  I am just probably not naming it correctly.

I have changed the settings to "backup_smf"
and the database created backup_smf

Can you tell me where I might be going wrong?  I just don't follow how you rename the database bit - when you say prefix, do you mean the original name of the database followed by backup_smf without _in front or what?  Help! :D
Title: Re: Database Backup
Post by: babjusi on November 14, 2009, 04:49:38 PM
Quote from: CerebralJam on November 14, 2009, 04:44:05 PM
Hi there, I have followed this thread with interest.  I did upgrade successfully to RC2 but as 75% of my mods do not have upgrades as yet I decided I needed to go back... I am just struggling with the database connection, even using the repair tool.  I am just probably not naming it correctly.

I have changed the settings to "backup_smf"
and the database created backup_smf

Can you tell me where I might be going wrong?  I just don't follow how you rename the database bit - when you say prefix, do you mean the original name of the database followed by backup_smf without _in front or what?  Help! :D

Did you choose for the upgrader to backup the tables prior to the backup? Did you do any backup at all btw, prior to the upgrade?
Title: Re: Database Backup
Post by: Norv on November 14, 2009, 04:52:23 PM
In case you used the backup feature of the upgrade script (during the upgrade, the checkbox to "backup your tables"), then you should have many different tables in your database now, named "backup_" + [your_normal_smf_prefix] + [tablename]. Meaning the new prefix (when you decide to use these) will be "backup_" + [your_normal_smf_prefix] .

Quote from: CerebralJam on November 14, 2009, 04:44:05 PM
I have changed the settings to "backup_smf"
Can you please tell, what setting ? The prefix should be "backup_smf_", if you previous prefix was "smf_".
Quote from: CerebralJam on November 14, 2009, 04:44:05 PM
and the database created backup_smf
Perhaps this is the misunderstanding: the database is the same, the backing up feature of the upgrader does not create another database. It duplicates all tables of your original database, into the same database, naming each copied table "backup_"+former name. So your database name should still be the previous name.
Title: Re: Database Backup
Post by: CerebralJam on November 14, 2009, 04:53:33 PM
Quote from: babjusi on November 14, 2009, 04:49:38 PM
Quote from: CerebralJam on November 14, 2009, 04:44:05 PM
Hi there, I have followed this thread with interest.  I did upgrade successfully to RC2 but as 75% of my mods do not have upgrades as yet I decided I needed to go back... I am just struggling with the database connection, even using the repair tool.  I am just probably not naming it correctly.

I have changed the settings to "backup_smf"
and the database created backup_smf

Can you tell me where I might be going wrong?  I just don't follow how you rename the database bit - when you say prefix, do you mean the original name of the database followed by backup_smf without _in front or what?  Help! :D

Did you choose for the upgrader to backup the tables prior to the backup? Did you do any backup at all btw, prior to the upgrade?

I chose to backup the database before upgrading to RC2

I have tables in my phpadmin files called backup_smf_
Title: Re: Database Backup
Post by: babjusi on November 14, 2009, 05:04:30 PM
Quote from: CerebralJam on November 14, 2009, 04:53:33 PM
Quote from: babjusi on November 14, 2009, 04:49:38 PM
Quote from: CerebralJam on November 14, 2009, 04:44:05 PM
Hi there, I have followed this thread with interest.  I did upgrade successfully to RC2 but as 75% of my mods do not have upgrades as yet I decided I needed to go back... I am just struggling with the database connection, even using the repair tool.  I am just probably not naming it correctly.

I have changed the settings to "backup_smf"
and the database created backup_smf

Can you tell me where I might be going wrong?  I just don't follow how you rename the database bit - when you say prefix, do you mean the original name of the database followed by backup_smf without _in front or what?  Help! :D

Did you choose for the upgrader to backup the tables prior to the backup? Did you do any backup at all btw, prior to the upgrade?

I chose to backup the database before upgrading to RC2

I have tables in my phpadmin files called backup_smf_

In that case all you gotta do is to upload the files of the version you had before you did the upgrade, then open the Settings.php file and change the db prefix in there to the backup_ smf and you should be all set.
Title: Re: Database Backup
Post by: CerebralJam on November 14, 2009, 05:07:45 PM
Thanks - I am nearly there.  I did upload all the files and then ran the repair_settings.php.  I missed the prefix on the settings, and only saw the db name, so that was my mistake.

I now have most of it working - except two of the mods when I click on the menu the buttons do not go to the mod.

I can see all the things I need in admin section so that is all there, just the link from the quiz to the quiz and the arcade to the arcade have seemed to have gone strange - any suggestions?
Title: Re: Database Backup
Post by: Norv on November 14, 2009, 05:13:05 PM
You might miss some files perhaps? Please note that sometimes FTP clients drop some files during transfer, and they don't necessarily tell it very visibly.
Try re-uploading the files, or let us know if you have some errors in the error log, as they might help understanding what can be wrong.
Title: Re: Database Backup
Post by: CerebralJam on November 14, 2009, 05:14:47 PM
Okay, thanks, will do!  :)
Title: Re: Database Backup
Post by: babjusi on November 14, 2009, 05:26:22 PM
Quote from: CerebralJam on November 14, 2009, 05:14:47 PM
Okay, thanks, will do!  :)

No problem, let us know how it will go.
Title: Re: Database Backup
Post by: CerebralJam on November 14, 2009, 07:24:03 PM
Just letting you know I've had some very hairy moments!

I decided to reinstall all my SMF files back onto the server overwriting all as I could not solve the issue of the links not working... (excluding the databases) and see if this solved the problem. 

It did but what worries me is the settings.php had info from my old webhost and I had had a problem with this that it crashed their server twice,  thus I moved!  I suddenly saw their favicon appear on my site and so I stopped the ftp - I was transferring stuff from my hard-drive to the new webhosts ftp server.

Is it possible for SMF to go to an ex hosts server and reactivate files and put them live, purely via the settings.php?  I need to ask this as they accused me of reinstalling and activating a closed account the other day when I first moved the site, and was not on theirs!  ...  Yesterday they told me I have no ftp access whatsoever so this is very worrying if it can do this.

This could be a serious loophole in security if at all possible so I am letting you know so that you can look into it, save it happening again to some other innocent party.  Perhaps if you could assure me this is not possible that would be good too.

Many thanks for all your help.  I think I have it sorted now... unless the old host deletes the files as I have asked and I lose it all LOL ...

Good night all!
Title: Re: Database Backup
Post by: Norv on November 14, 2009, 07:59:29 PM
Quote from: CerebralJam on November 14, 2009, 07:24:03 PM
It did but what worries me is the settings.php had info from my old webhost and I had had a problem with this that it crashed their server twice,  thus I moved!  I suddenly saw their favicon appear on my site and so I stopped the ftp - I was transferring stuff from my hard-drive to the new webhosts ftp server.
If SMF had your old host's settings (SMF being on the new host) then it will fail connecting to the database, because it tries to connect to the current host with the name and password and everything else which worked on the old one, but will probably simply not work here. It would try to use the paths as they were on the old host's computer, too, but it would try to use them on the computer of the new host, and most likely your new host doesn't even have the same paths, so it will fail.

It's like you have your files on your computer on D:\mes documents\apa3\summer97, and you have a program where you saved this path in favorites. Then you transfer the program to another's computer. The program will search for D:\mes documents\apa3\summer97 on his computer, will probably not find it, and the bookmark will be broken. It doesn't mean it would try to connect to your computer, even less that it tries to put files on yours out of the blue.

As before, you need to correct the data in Settings.php directly or by running repair_settings.php, and perhaps in the old database as well.
You could save this "new" Settings.php then in/near the files of the old backup, just for your peace of mind.

favicon is a little file, favicon.ico, which should be at the root of the site, in order to appear when you browse your pages (perhaps you have it directly in SMF directory). Check it out, in case you did not know it, then I presume your old host added it, you can safely remove it or replace it with whatever image you want for your site.

Quote from: CerebralJam on November 14, 2009, 07:24:03 PM
Is it possible for SMF to go to an ex hosts server and reactivate files and put them live, purely via the settings.php?
No.

Quote from: CerebralJam on November 14, 2009, 07:24:03 PM
I need to ask this as they accused me of reinstalling and activating a closed account the other day when I first moved the site, and was not on theirs!  ...  Yesterday they told me I have no ftp access whatsoever so this is very worrying if it can do this.
If you have no access to the former FTP account, then you could not (with any program, be it your FTP client or SMF or any other) access the former FTP account.

Quote from: CerebralJam on November 14, 2009, 07:24:03 PM
Many thanks for all your help.  I think I have it sorted now... unless the old host deletes the files as I have asked and I lose it all LOL ...
I thought the files are on the new host's server? I guess the old host can delete the copy from their own server all they want, as I understand you do not wish to come back to them, have them on the new host's server, and you have a backup on your harddisk anyway.

Quote from: CerebralJam on November 14, 2009, 07:24:03 PM
Good night all!
Thank you, good night! It has been a long day...