You can just grab all threads/posts that don't exist. You can alter the above queries as follows:
Code:
INSERT INTO post
(SELECT *
FROM post7
WHERE NOT threadid IN (SELECT threadid FROM thread))
Code:
INSERT INTO thread
(SELECT *
FROM thread7
WHERE NOT threadid IN (SELECT threadid FROM thread))
EDIT: You have to do the post query first otherwise the deleted thread will already be restored in the thread table.