ispCP - Board - Support
[HowTo] Migrate folders from Uebimiau (VHCS2) to Squirrelmail (IspCP omega) - Printable Version

+- ispCP - Board - Support (http://www.isp-control.net/forum)
+-- Forum: ispCP Omega Contributions Area (/forum-40.html)
+--- Forum: Howtos (/forum-41.html)
+--- Thread: [HowTo] Migrate folders from Uebimiau (VHCS2) to Squirrelmail (IspCP omega) (/thread-7867.html)



[HowTo] Migrate folders from Uebimiau (VHCS2) to Squirrelmail (IspCP omega) - mac86 - 09-15-2009 09:25 AM

Hi,

this is how I get moved webmail users folders (sent, trash, and user custom folders) from VHCS to ISPCP

CAUTION: this code worked for me. If you want to use it, you have to check it. Consider like a ALPHA status pieces of code.

----

First, we have to create some folders inside /var/mail/virtual with next script.

Code:
#!/bin/sh

cd /var/mail/virtual/

for doms in `ls -1|egrep  '\.net|gov|com'`; do



        for i  in `ls -1 $doms` ; do
            echo "mkdir -p  $doms/$i/.Sent/cur"
            mkdir -p  $doms/$i/.Sent/cur
            echo "mkdir -p  $doms/$i/.Sent/tmp"
            mkdir -p  $doms/$i/.Sent/tmp
            echo "mkdir -p  $doms/$i/.Sent/new"
            mkdir -p  $doms/$i/.Sent/new
            echo "mkdir -p  $doms/$i/.Trash/cur"
            mkdir -p  $doms/$i/.Trash/cur
            echo "mkdir -p  $doms/$i/.Trash/tmp"
            mkdir -p  $doms/$i/.Trash/tmp
            echo "mkdir -p  $doms/$i/.Trash/new"
            mkdir -p  $doms/$i/.Trash/new
        done


done

echo "chown -R vmail:mail *"
chown -R vmail:mail *

Next, we have to move folders from vhcs2 to ispCP omega with next script:

Code:
#!/bin/bash

cd /var/www/vhcs2/gui/tools/webmail/database/

script="./script";
cat /dev/null > $script


for i in `ls -1`; do


        case $i in
                "_sessions") continue;
                ;;
                "_cached_templates") continue;
                ;;
        esac;

        dominio=`echo $i | awk -F_ '{print $2}' `
        usuario=`echo $i | awk -F_ '{print $1}' `

        ls -1 $i | while read  j; do


                case $j in

                        "inbox")        continue;
                        ;;

                        "_infos")               continue;
                        ;;

                        "_attachments")         continue;
                        ;;

                        "sent")         echo   "mv '$i/$j/'*  /var/mail/virtual/$dominio/$usuario/.Sent/cur/"
                                        echo   "mv -v '$i/$j/'*  /var/mail/virtual/$dominio/$usuario/.Sent/cur/"  >> $script
                                        continue;
                        ;;

                         "trash")       echo "mv '$i/$j/'*  /var/mail/virtual/$dominio/$usuario/.Trash/cur/"
                                        echo "mv -b '$i/$j/'*  /var/mail/virtual/$dominio/$usuario/.Trash/cur/" >> $script
                                        continue;
                        ;;


                esac;

                echo 'ANALIZANDO CARPETA  $j'

                echo "mkdir -p  '/var/mail/virtual/$dominio/$usuario/.${j}'"
                echo "mkdir -p  '/var/mail/virtual/$dominio/$usuario/.${j}'"  >> $script
                echo "mv '$i/$j/'* '/var/mail/virtual/$dominio/$usuario/.$j/'"
                echo "mv -v '$i/$j/'* '/var/mail/virtual/$dominio/$usuario/.$j/'"  >> $script
                echo

        done;

done


chown -R vmail:mail /var/mail/virtual/*

This code will create a script called "script" in your directory
/var/www/vhcs2/gui/tools/webmail/database

you must to run it with:

Code:
sh ./script

And hopellyfull you have in your squirrelMail your vhcs2 customers folders.

Smile