Howto migrate s9y blog to WordPress

Migrate s9y posts
– use import from RSS, rss = http://blog-s9y.hostsname.sk/feed/rss.php?version=2.0&all=1

And then update to whole body:

UPDATE wp_posts w, sp_entries s 
  SET w.post_content = CONCAT(s.body , '<!--more-->', s.extended) 
    COLLATE utf8_general_ci
WHERE w.post_title = s.title COLLATE utf8_general_ci ;

Migrate s9y comments

INSERT into wp_comments
  (comment_ID, comment_post_ID, comment_author, comment_author_email, comment_author_url, 
   comment_author_IP, comment_date, comment_date_gmt, comment_content, comment_karma, 
   comment_approved, comment_parent, user_id)
SELECT sp_comments.id, wp_posts.ID, sp_comments.author, email, url, ip, 
  FROM_UNIXTIME(sp_comments.timestamp), FROM_UNIXTIME(sp_comments.timestamp),
  sp_comments.body, 0, 1, parent_id, 1
FROM sp_comments
INNER JOIN sp_entries ON (sp_comments.entry_id  = sp_entries.id)
INNER JOIN wp_posts on (sp_entries.title = wp_posts.post_title COLLATE utf8_general_ci ) ;


Generate HTTP rewrite rules
(some articles ID’s may have be changed during migration)

SELECT s.id, CONCAT(
  'Redirectmatch permanent ^/archives/', s.id, '-(.*).html$ /',
  REPLACE(LEFT(w.post_modified, 10), '-', '/'),
  '/', w.post_name, '/') AS new_url
FROM sp_entries AS s
INNER JOIN wp_posts AS w ON (
  w.post_title = s.title COLLATE utf8_general_ci
  AND w.post_type = 'post') ;