Skip to content

Instantly share code, notes, and snippets.

@danteoh
Created May 9, 2018 18:51
Show Gist options
  • Save danteoh/f366a9a6a6a66a771e45b260326a2ee7 to your computer and use it in GitHub Desktop.
Save danteoh/f366a9a6a6a66a771e45b260326a2ee7 to your computer and use it in GitHub Desktop.
Scripts to migrate Wordpress uploads to S3 for WP Offload S3 Lite

Improvements are welcome!

-- replace YOURREGION and YOURBUCKET accordingly
-- this will dump a number of php lines for you to run. paste all these rows into a file and run it. Use the output in the next file
select CONCAT(
"<?php print(\"(",
ID,
", 'amazonS3_info', '\".str_replace('O:8:\"stdClass\"', 'a', serialize(json_decode(\"",'{ \\"region\\": \\"YOURREGION\\", \\"bucket\\": \\"YOURBUCKET\\", \\"key\\": \\"', SUBSTRING(guid, 31), '\\"}"\))) ."\'),") ?>') from db224570_1clk_wordpress_qq175dggRSHpFIs1.wp_posts where post_type = 'attachment';
-- paste the output from dump.sql (after running it through PHP) onto line 3:
insert into wp_postmeta (post_id, meta_key, meta_value) values
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment