Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #11  
Old 09-03-2015, 01:07 PM
squidsk's Avatar
squidsk squidsk is offline
 
Join Date: Nov 2010
Posts: 969
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by RichieBoy67 View Post
I am very confused by these. I do not know where to begin with the script. I have the first query run first on which database?

Thanks Guys

Lynne, You are not kidding!
Sorry I've reformated the queries to make it more clear which db is which

This should restore all posts removed from the livedb that are in the backupdb that do not belong to threads that still exist on your live db. (i.e. if you deleted a post from a thread but the thread is still on the live db it won't be restored)
Code:
INSERT INTO libedb.post
(SELECT *
FROM backupdb.post
WHERE NOT threadid IN (SELECT threadid FROM livedb.thread))
The second query restores all threads that have been deleted.
Code:
INSERT INTO livedb.thread
(SELECT *
FROM backupdb.thread
WHERE NOT threadid IN (SELECT threadid FROM livedb.thread))
The results obviously won't include threads/posts deleted before the backup was made.
Reply With Quote
Благодарность от:
RichieBoy67
  #12  
Old 09-04-2015, 12:45 AM
RichieBoy67's Avatar
RichieBoy67 RichieBoy67 is offline
 
Join Date: Apr 2004
Location: CT - Down in a hole..
Posts: 3,057
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks,

The issue though is not missing or deleted threads.. They are there, it is missing posts only. I am not sure what happened to them but it was done using impex.

Bottom line it is only posts that need to be imported.

Thanks so much for your help.
Reply With Quote
  #13  
Old 09-04-2015, 12:27 PM
squidsk's Avatar
squidsk squidsk is offline
 
Join Date: Nov 2010
Posts: 969
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Then just use the first query but take out the NOT in the where clause.
Reply With Quote
  #14  
Old 09-06-2015, 12:27 AM
RichieBoy67's Avatar
RichieBoy67 RichieBoy67 is offline
 
Join Date: Apr 2004
Location: CT - Down in a hole..
Posts: 3,057
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by squidsk View Post
Then just use the first query but take out the NOT in the where clause.
Thanks!

I will try this today.

--------------- Added 06 Sep 2015 at 05:40 ---------------

Ok, this is what I ran on the live database:

PHP Code:
INSERT INTO muscle-mecca-BackUp.post
(SELECT *
FROM muscle-mecca-BackUp.post
WHERE threadid IN 
(SELECT threadid FROM muscle-mecca-BackUp.thread)) 
and this is the error I got:

PHP Code:
#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 '-mecca-BackUp.post
(SELECT *
FROM muscle-mecca-BackUp.post
WHERE threadid IN 
' at line 1 
Did I mess this up?
Reply With Quote
  #15  
Old 09-06-2015, 04:03 PM
squidsk's Avatar
squidsk squidsk is offline
 
Join Date: Nov 2010
Posts: 969
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Three things: first I think you want to be inserting into your live db not your backup db, second I think you want the threadid to be the ones from the live db (i.e. only grab posts for threads that are still in the live db), and third the reason I think you're getting the error is that you might require backticks or double quotes around your db name for the backupdb.
Reply With Quote
  #16  
Old 09-07-2015, 02:39 AM
RichieBoy67's Avatar
RichieBoy67 RichieBoy67 is offline
 
Join Date: Apr 2004
Location: CT - Down in a hole..
Posts: 3,057
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

yes, those are both back ups.. that was the correct database as it is the back up of my main database. The other one is the back up of the back up.

I will try with the quotes.

--------------- Added [DATE]1441600859[/DATE] at [TIME]1441600859[/TIME] ---------------

Actually I think you may be right either that or I changed the names incorrectly when I copied it here.

--------------- Added [DATE]1441602633[/DATE] at [TIME]1441602633[/TIME] ---------------

I am not sure what I am missing but have tried everything and nothing works..keep getting the syntax error. I believe we need asterisks.
Reply With Quote
  #17  
Old 09-07-2015, 06:50 PM
squidsk's Avatar
squidsk squidsk is offline
 
Join Date: Nov 2010
Posts: 969
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If that's the query there's a problem with your tables, both the source and destination post tables are the in the same db. So you're inserting all posts from db1 into db1 if the threads are in db1, which doesn't make any sense, so that's likely what the syntax error is about. If you're restoring posts, then you have to restore from one db into the other based off the threads in the destination db.
(i.e. restore posts into db1 from db2 where the threads are in db1) Your current query is doing restore posts into db1 from db1 where threads are in db1, which won't accomplish anything.
Reply With Quote
  #18  
Old 09-08-2015, 02:31 AM
RichieBoy67's Avatar
RichieBoy67 RichieBoy67 is offline
 
Join Date: Apr 2004
Location: CT - Down in a hole..
Posts: 3,057
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, I changed the databases and still got the errors.I went by your directions.

PHP Code:
INSERT INTO "muscle-mecca-BackUp.post"
(SELECT *
FROM meccaaugust-backup.post
WHERE threadid IN 
(SELECT threadid FROM "muscle-mecca-BackUp.thread")) 
The august base is the back up. The other is the live.

Your instructions:

PHP Code:
INSERT INTO libedb.post (SELECT FROM backupdb.post WHERE NOT threadid IN (SELECT threadid FROM livedb.thread)) 
Reply With Quote
  #19  
Old 09-09-2015, 10:57 PM
RichieBoy67's Avatar
RichieBoy67 RichieBoy67 is offline
 
Join Date: Apr 2004
Location: CT - Down in a hole..
Posts: 3,057
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If anyone can help me finish this I will glady donate a few $.

Keep in mind these are both back up databases that are live in phpadmin. I did not want to run this on my live site until I get it working.

Don't let the "backup" in the database names confuse you. August is the back up.. the other is the one I am trying to add tyhe posts too.

Thanks
Reply With Quote
  #20  
Old 09-10-2015, 06:04 PM
squidsk's Avatar
squidsk squidsk is offline
 
Join Date: Nov 2010
Posts: 969
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try changing the query to insert ignore, as insert ignore will ignore constrains like primary key constraints.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:01 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04799 seconds
  • Memory Usage 2,271KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (4)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (1)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete