Forums

[resolved] How to restore broken database - site down (10 posts)

  1. kjetilgf
    Member
    Posted 4 years ago #

    Urgent: I have partly destroyed our site's database and need advice on how to restore it.
    I'm sorry if this is answered in the codex, but I'm far off on a cell-phone connection without much possibility to search.
    Basically I need to restore the database, importing a database copy from a week back. I'll do this after installing WP in a fresh database.
    1st problem: The db copy is 3,4 MB, while the max size to import is 2 MB. Any workaround?
    (I've learned earlier that I should restore the complete db, not just single tables since they influate on each other.)
    2nd: What would be the correct procedure - after installing WP, should I first import the database and then install the plugins or opposite?
    Other advice/ crucial links?
    Thanks a lot
    Kjetil
    dolcevita.no

  2. kjetilgf
    Member
    Posted 4 years ago #

    I was really hoping to get an answer on this one...
    Especially on the part with the database being too big. I only have access to the database via WP - and maybe PHPMyAdmin in a while - but I hardly have time to wait for that.
    Anyone - please?

  3. Ivovic
    Member
    Posted 4 years ago #

    3.4 meg isn't huge... is there any chance of contacting your host and asking for them to increase the php upload size limitation from 2mb (default) to 5mb or more? this setting is in php.ini.

    Depending on your hosting situation you may be able to do this yourself, if you have access to your own php.ini.

    phpMyAdmin will suffer the same issue.

    I don't suppose you have SSH access to your hosting account do you? you can import via the command line if you can FTP up your backup.

    If your host doesn't want to increase the max upload size, you may want to ask them if they wouldn't mind restoring your backup via the command line for you...

    Your other choices are somewhat limited.

    PS: you should be on vacation not screwing up your database :P

  4. Ivovic
    Member
    Posted 4 years ago #

    also, remember once your backup is restored you'll have to do the search/replace thing again... due to moving your blog.

    .... unless you took a backup of your DB *after* you did that already.

    ...

    also, you asked about the correct procedure, something about plugins and so on... you really shouldn't need to do anything with plugins unless you screwed up the physical files as well.

    just restore the DB.

  5. kjetilgf
    Member
    Posted 4 years ago #

    Great - you're back!
    What confused me was that there's a 2 MB limitation even when I try to import the backup to the local server (running on my computer) - and also from what I've seen of forum discussions this is a well-known issue.
    Also, it turns that my host has a 22MB limit, so the answer is somewhere in WP - I believ.
    It seems that the only way to import a 3,4 MB backup file is through phpMyAdmin (not WP) or by letting my host do it. Sounds, then, like i will have to set up a second database where I prepare everything before I delete the one that's screwed up. If I overwrite the live database i risk to loose more (though I can make a backup here too)

    That is on the web server.
    (Locally, I'm the host, and I haven't got the faintest idea on how to increase any limits - nor about installing phpMyAdmin. I might manage it using MySQL Administrator (this is on Mac))
    Luckily(?) I won't have to run any new search and replace. I've set up the site with two WP installations. If one goes down, peple can still enjoy the other. The broken one now is just with our blog and forum, the one we struggled with the other day contains the site itself.
    Thinking the right way?
    Kjetil

  6. Ivovic
    Member
    Posted 4 years ago #

    I wouldn't worry about creating a second DB then switching them around... simply rename the index.php in the root of your wordpress installation to index.NOTNOW ;)

    optionally put up an index.html page that says "be right back..."

    then do the database restoration which should only take a few minutes... then put the files back the way they were.

    if you're your own host, then I seriously suggest you increase your php upload limit instead of screwing around.

    change the values of post_max_size and upload_max_filesize in your php.ini... if your server is configured to use suexec (most cpanel installations are, for example) then put this in your htaccess file:

    php_value post_max_size 10M
    php_value upload_max_filesize 10M
    php_value max_execution_time 3600

    the values are just a guide.

  7. kjetilgf
    Member
    Posted 4 years ago #

    I like the word "just" - many things are so simple when you know how :o)
    Well, I believe I stumbled in the Restore part and really need some advice to make it right.
    I've set up a WP installation on my Mac. (I'm not my own host, I just test out things locally instead of screwing it up on the web). Logged in and saw WP working, and in MySQL Administrator I saw all the basic tables in place. I also replaced the original wp-contents folder on the local "server" with a copy of that running on the web.
    Then I used MySQL Administrator to restore: I picked the db backup file and then with all tables selected I happily clicked "restore backup". All the tables showed up in the catalogue there, I assumed the original tables were overwritten.
    Now, in WP admin everythings a mess. I just get a page showing errors like this:
    Warning: array_keys() [function.array-keys]: The first argument should be an array in /Library/WebServer/Documents/wplokalblogg/wp-includes/widgets.php on line 676
    ...all pointing to widgets.php and pluggable.php
    I don't know where I stepped wrong. Maybe when importing (restoring) all the tables. Should I import all? (would think that's the safest) Should I activate the plugins before restoring? (I guess the tables they create will be overwritten when restoring, so does it make any difference?)

    Well...
    I repeated the process with just another database and WP installation - still just locally - it takes a few seconds.
    This time I've also copied in all the themes and plugins into the existing wp-content/plugins and /themes folders, not replacing any of the original files - in case some wrong permissions could have messed up things, though not likely.
    I've stopped there so far untill I know the next step.
    Strangely I haven't found any solution even if I've now had time to search both the codex and forums.
    Could you please give me a hand?
    Kjetil
    - confused by databases

    PS You saw that my host has a php upload limit of 22 MB - could be easier to do things online, maybe
    PPS I also tried to find hte php.ini file locally. It must be there, but a serch reveals nothing.

  8. Ivovic
    Member
    Posted 4 years ago #

    Yeah, this confusion with doing it locally vs doing it directly on your host is a little odd. Your emergecy isn't local, surely...

    I have to admit I'm a little confused by what you're actually doing here.

    What's all this with themes and plugins? that seems completely unrelated to a database restoration. Part of the reason you get into so much trouble here is that you confuse the issue by doing 20 things at once.

    Scientific method says change ONE thing, then observe the results.

    If your host's PHP upload settings are sufficient (and they are), then restoring the database should be *very* easy... if you wanted to test this process locally, and your php settings are not allowing you to do that, then all I can say is change them.

    When a database breaks it doesn't take the wordpress files and plugins with it... I wish I could understand why you're tooling around with those when you should be restoring your DB to your live host.

    If you have a backup of your DB that you're confident in.. drop all the tables in your existing DB using phpMyAdmin, then import your backup. All of it, not just one or two tables.

    "- confused by databases"

    I'm confused by the approach you're taking, because I don't understand WHY you are tooling around with wordpress files / plugin files / theme files.

  9. kjetilgf
    Member
    Posted 4 years ago #

    Its just because I don't know enough about how databases work, what's included in the backup, nor exactly what happens if I run a restore (what's replaces, overwritten, merged) - nor exactly how to do this in phpMyAdmin.
    The answer now is simple, I believe:
    I'll make a backup from the site as it is now (just to feel better) and ask my host to replace the database with the latest backup they have made before I messed up the database.
    Kj

  10. kjetilgf
    Member
    Posted 4 years ago #

    For someone as little confident with databases etc as me, the solution was in fact easy:
    I copied out the html from all the latest week's posts and then let our host replace the database with a backup. Afterwards I just had to re-write/insert the missing posts.

Topic Closed

This topic has been closed to new replies.

About this Topic