Assume you refer to the GUI and not an existing text command?
We are talking about more than 400 segments with different contacts. That’s a lot of manual clicking in the gui. Assume each export / import takes at least 2 min, equal to 800 min of work if it’s done manually for each segment.
Was thinking of writing a script to export each segment to a csv file and then have a script to import them again. Thoughts?
I check both the API solution and the db solution.
DB solution:
For the db it looks like the segments “lead list” and contacts are linked through the table “lead_list_leads”. See attached picture.
So I would need to export these 3 tables, though the question is if the db structure for these 3 tables have changed from M4 to M5?
sudo mysql;
use mymauticdb;
SELECT table_schema AS “Database”, SUM(data_length + index_length) / 1024 / 1024 / 1024 AS “Size (GB)” FROM information_schema.TABLES GROUP BY table_schema;
SELECT table_name AS “Table”,
ROUND(((data_length + index_length) / 1024 / 1024), 2) AS “Size (MB)”
FROM information_schema.TABLES
WHERE table_schema = “mauticdb”
ORDER BY (data_length + index_length) DESC;
Clean the select tables that needed cleaning:
In my case the SQL query showed that “email_stats” table was huge and needed some cleaning.
Now we know what table to clean up and I prefer not to touch the db my self so I used the housekeeping plugin. Credit: leuchtfeuer Tutorial - Housekeeping Plugin for Mautic
a. Download the .zip file from their github:
b. Transfer the .zip file to your mautic plugins folder …/docroot/plugins
c. Unpack
d. Rename the unzipped folder to "LeuchtfeuerHousekeepingBundle”
e. Cache clear
f. Reload plugins
g. If necessary, activate the plugin from the webadmin tool in mautic.
Run Leuchtfeuer’s housekeeping plugin for the specific table you need cleaning.
I needed to clean the “email_stats”
bin/console leuchtfeuer:housekeeping -m -d [clean for days older than this]
-m is for email_stats
-d is for what days to clean up. It only removed data older than this value.
If you never cleaned the database, then the cleaning can take a long time.
My tip is to start with a few days close to when you made the installation and test.
NOTE:
Cleaning easily crash if you try to clean too many days in a row, recommend to use the (.sh) script found on the github page for housekeeping.
It run one day at the time, avoiding the crash.
The script from the readme at the github also need slight modification to run.
When Housekeeping plugin is done, your database is still taking up the previous space but it’s filled with empty information.
To resolve this and free up diskspace by making the database smaller, run the sql query:
“OPTIMIZE table email_stats;”