Gebruikersdata verwijderen (WordPress-databases)

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen

De databases achter webshops, bevatten een hoop persoonsgegevens. Niet alleen rondom klanten en bestellingen, maar (helaas) ook bv. IP-adressen. Als ik zo'n database later gebruik voor andere toepassingen (bv. om een Google Ads-campagne op te baseren), dan is het zaak om deze persoonsgegevens te verwijderen.

Soms kan die data gewoon verwijderd worden. In andere gevallen wil ik die data wellicht liever anonimiseren - Dat vereist verschillende procedures.

Casus aug. 2020: Gebruikersdata quick-&-dirty verwijderen

Deze sproc had ik geschreven in aug. 2020. Het betreft een situatie dat ik een WordPress-database gebruik als input voor een Google Ads-campagne. Ik heb dus alleen productgegevens nodig, en misschien taxonomische gegevens. Deze tabel wordt dus niet meer gebruikt voor WordPress-sites. Vandaar dat veel tabellen compleet verwijderd worden:

CREATE DEFINER=`jeroen`@`localhost` PROCEDURE `remove_user_data_from_wp_tmp`()
BEGIN
#
# Delete everything that contains private data
###############################################################################################################################
#
# * This routine is overly broad: Rather delete too much than too little
# * *not* deleted: taxonomical data: Might come handy!
#
# Table wp_posts
###############################################
#
# Keep certain rows - Throw away the remainder
#
delete from
   wp_tmp.wp_posts 
where 
   (
      post_type <> "product"
      or
      post_type <> "product_variation"
   );


###############################################
# Drop complete tables
###############################################
#
drop table if exists wp_tmp.wp_actionscheduler_actions;
drop table if exists wp_tmp.wp_actionscheduler_claims;
drop table if exists wp_tmp.wp_actionscheduler_groups;
drop table if exists wp_tmp.wp_actionscheduler_logs;
drop table if exists wp_tmp.wp_aws_cache;
drop table if exists wp_tmp.wp_aws_index;
drop table if exists wp_tmp.wp_b2s_posts_favorites;
drop table if exists wp_tmp.wp_b2s_posts_sched_details;
drop table if exists wp_tmp.wp_b2s_user_network_settings;
drop table if exists wp_tmp.wp_blc_filters;
drop table if exists wp_tmp.wp_blc_instances;
drop table if exists wp_tmp.wp_blc_links;
drop table if exists wp_tmp.wp_blc_synch;
drop table if exists wp_tmp.wp_feedmanager_channel;
drop table if exists wp_tmp.wp_feedmanager_country;
drop table if exists wp_tmp.wp_feedmanager_feed_status;
drop table if exists wp_tmp.wp_feedmanager_field_categories;
drop table if exists wp_tmp.wp_feedmanager_product_feed;
drop table if exists wp_tmp.wp_feedmanager_product_feedmeta;
drop table if exists wp_tmp.wp_feedmanager_source;
drop table if exists wp_tmp.wp_users;
drop table if exists wp_tmp.wp_usermeta;
drop table if exists wp_tmp.wp_b2s_posts;
drop table if exists wp_tmp.wp_b2s_posts_drafts;
drop table if exists wp_tmp.wp_b2s_posts_network_details;
drop table if exists wp_tmp.wp_b2s_user;
drop table if exists wp_tmp.wp_b2s_user_contact;
drop table if exists wp_tmp.wp_commentmeta;
drop table if exists wp_tmp.wp_comments;
drop table if exists wp_tmp.wp_mollie_pending_payment;
drop table if exists wp_tmp.wp_newsletter;
drop table if exists wp_tmp.wp_newsletter_emails;
drop table if exists wp_tmp.wp_newsletter_sent;
drop table if exists wp_tmp.wp_newsletter_stats;
drop table if exists wp_tmp.wp_newsletter_user_logs;
drop table if exists wp_tmp.wp_options;	# Bevat oa. SMTP-wachtwoord!
drop table if exists wp_tmp.wp_postmeta;
drop table if exists wp_tmp.wp_usermeta;	# Lots of private data!
drop table if exists wp_tmp.wp_wc_customer_lookup;


# Remove everything related to WordFence
############################################
#
drop table if exists wp_tmp.wp_wfblockediplog;	# Seems to contain IP adresses
drop table if exists wp_tmp.wp_wfblocks7;
drop table if exists wp_tmp.wp_wfconfig;
drop table if exists wp_tmp.wp_wfcrawlers;
drop table if exists wp_tmp.wp_wffilechanges;
drop table if exists wp_tmp.wp_wffilemods;
drop table if exists wp_tmp.wp_wfhits;
drop table if exists wp_tmp.wp_wfhoover;
drop table if exists wp_tmp.wp_wfissues;
drop table if exists wp_tmp.wp_wfknownfilelist;
drop table if exists wp_tmp.wp_wflivetraffichuman;
drop table if exists wp_tmp.wp_wflifelocs;
drop table if exists wp_tmp.wp_wflocs;
drop table if exists wp_tmp.wp_wflogins;	# Contains email addresses & IP addresses
drop table if exists wp_tmp.wp_wfls_2fa_secrets;
drop table if exists wp_tmp.wp_wfls_settings;
drop table if exists wp_tmp.wp_wfpendingissues;
drop table if exists wp_tmp.wp_wfreversecache;
drop table if exists wp_tmp.wp_wfsnipcache;
drop table if exists wp_tmp.wp_wfstatus;
drop table if exists wp_tmp.wp_wftrafficrates;


# wp_woocommerce
############################################
#
drop table if exists wp_tmp.wp_wc_admin_note_actions;
drop table if exists wp_tmp.wp_wc_admin_notes;
drop table if exists wp_tmp.wp_wc_category_lookup;
drop table if exists wp_tmp.wp_wc_download_log;
drop table if exists wp_tmp.wp_wc_order_coupon_lookup;
drop table if exists wp_tmp.wp_wc_order_product_lookup;
drop table if exists wp_tmp.wp_wc_order_stats;
drop table if exists wp_tmp.wp_wc_order_tax_lookup;
drop table if exists wp_tmp.wp_wc_product_meta_lookup;
drop table if exists wp_tmp.wp_wc_tax_rate_classes;
drop table if exists wp_tmp.wp_wc_webhooks;
drop table if exists wp_tmp.wp_wcpdf_invoice_number;
drop table if exists wp_tmp.wp_wfblocks7;
drop table if exists wp_tmp.wp_wfconfig;
drop table if exists wp_tmp.wp_wflocs;
drop table if exists wp_tmp.wp_wfnotifications;
drop table if exists wp_tmp.wp_woocommerce_api_keys;
drop table if exists wp_tmp.wp_woocommerce_attribute_taxonomies;
drop table if exists wp_tmp.wp_woocommerce_downloadable_product_permissions;
drop table if exists wp_tmp.wp_woocommerce_log;
drop table if exists wp_tmp.wp_woocommerce_order_itemmeta;
drop table if exists wp_tmp.wp_woocommerce_order_items;
drop table if exists wp_tmp.wp_woocommerce_payment_tokenmeta;
drop table if exists wp_tmp.wp_woocommerce_payment_tokens;
drop table if exists wp_tmp.wp_woocommerce_sessions;
drop table if exists wp_tmp.wp_woocommerce_shipping_zone_locations;
drop table if exists wp_tmp.wp_woocommerce_shipping_zone_methods;
drop table if exists wp_tmp.wp_woocommerce_shipping_zones;
drop table if exists wp_tmp.wp_woocommerce_tax_rate_locations;
drop table if exists wp_tmp.wp_woocommerce_tax_rates;

# Various
############################################
#
drop table if exists wp_tmp.wp_wpf_filters;
drop table if exists wp_tmp.wp_wpf_modules;
drop table if exists wp_tmp.wp_wpf_modules_type;
drop table if exists wp_tmp.wp_wpf_usage_stat;
drop table if exists wp_tmp.wp_wpforms_tasks_meta;
drop table if exists wp_tmp.wp_yith_wcwl;
drop table if exists wp_tmp.wp_yith_wcwl_lists;
drop table if exists wp_tmp.wp_yoast_indexable;
drop table if exists wp_tmp.wp_yoast_indexable_hierarchy;
drop table if exists wp_tmp.wp_yoast_migrations;
drop table if exists wp_tmp.wp_yoast_primary_term;
drop table if exists wp_tmp.wp_yoast_seo_links;
drop table if exists wp_tmp.wp_yoast_seo_meta;


# wp_shortpixel
############################################
#
# At the end because of a foreign key constraint
#
drop table if exists wp_tmp.wp_shortpixel_meta;
drop table if exists wp_tmp.wp_shortpixel_folders;

END