giovedì 1 gennaio 2015

[bash CPanel] hostmonster / bluehost mail migration between customers

I have a reseller plan bound to a company which was sold. I need to migrate some domains from that plan to another reseller plan I opened for my personal stuff.

Hostmonster / Bluehost asks 100$ for a domain migration (5 domains, 20 email folders).

I have all IMAP folders, so I arranged to do it myself and save that bucks. It's just a matter of recursively merging remote directories. You can also merge mailboxes, e.g. put info@aaa.com into johndoe@aaa.com etc etc.

SSH must be enabled on both CPanels.

  1. Unassign your domain from the old plan: it states that emails will be deleted... sure but it wont delete nor the corrsponding folders, neither the web server folders, so don't panic.
  2. Assign your domain to the new plan, it only asks you the old domain password.
  3. Enter the old SSH and type
rsync -Purva --ignore-existing --progress /home2/olddomain/mail/olddomain.com/oldaddress/ newdomain@ newdomain.com:/home2/newdomain/mail/newdomain.com/newaddress

-P enables the --ignore-existing directive
-u saves the the newer file in case of name conflict (impossible, however it's healtier to enable it)
-r recursive
-v verbose, redunded with --progress however healtier than only one
-a archive, so recursive and safer, ok I admit that I redunded a lot but it actually works.

The source folder is intentionally trailed with a / in order to retain the paths.

You could also do it for a whole domain...

rsync -Purva --ignore-existing --progress /home2/olddomain/mail/olddomain.com/ newdomain@ newdomain.com:/home2/newdomain/mail/newdomain.com

Better save your money and offer me a pizza :-)