How to back up or migrate affiliate data

The best way to back up or migrate affiliate data is to export and import your MySQL database directly via phpMyAdmin or similar as shown in this WordPress codex article: Moving WordPress.

You can also use several different plugins that allow you to back up affiliate data:

When doing a MySQL dump of your database, you may run into the following error: #1227 - Access denied; you need (at least one of) the SUPER privilege(s) for this operation

To resolve the error, you can simply back up everything except the wp_affiliate_wp_campaigns table. The wp_affiliate_wp_campaigns table is not an actual table, it is a "view". If you skip exporting the wp_affliate_wp_campaigns view, the problem should go away. Since the campaigns view is created automatically from the referrals / visits table, you do not need to include that in your backups. The campaigns view will automatically reflect the changes that happen in the referrals / visits tables.

Note: Your MySQL user does not necessarily need root access to create a view, but you will need to add the required privileges to create a view like Create_view_priv and Super_priv as shown here: Privileges Provided by MySQL. Make sure that the user has the CREATE VIEW privilege in order to use the CREATE VIEW statement for the view.