You can find 3 scripts shipped in iRedMail: iRedMail-x.y.z/tools/create_mail_user_*.
To migrate LDAP mail accounts from old iRedMail server, you can simply export mail accounts in LDIF format with phpLDAPadmin, then import into new iRedMail server.
Note: New version of iRedMail probably add new attributes/value for mail accounts, the simplest way to find them is comparing this script shipped in different iRedMail versions: iRedMail-x.y.z/create_mail_user_OpenLDAP.sh, then add missing attributes/values manually with phpLDAPadmin or command line. Another way is checking detailed iRedMail upgrade tutorials for your old iRedMail version, we provides solutions to solve it in tutorials.