[ Index ]
 

Code source de vtiger CRM 5.0.2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/pkg/bin/ -> datamigration.bat (source)

   1  echo off
   2  set ins_dir4_0_1=%~1
   3  set BINDIR=%cd%
   4  set VTIGER_HOME=%cd%
   5  echo VTIGERHOME=%VTIGER_HOME%
   6  set version="4.0.1"
   7  
   8  :getinstalldir
   9  if NOT "X%ins_dir4_0_1%" == "X" goto checkdir
  10  
  11  echo "*******************"
  12  echo "*******************"
  13  echo
  14  echo
  15  
  16  set /P diffmac1="Is the vtiger CRM 4.0.1 mysql db in the same machine as the vtigerCRM4_2GA mysql db installation? (Y/N): "
  17  echo
  18  echo
  19  if "%diffmac1%"=="Y" goto samemac
  20  if "%diffmac1%"=="y" goto samemac
  21  
  22  set diffmac_uname=
  23  set diffmac_password=
  24  set diffmac_port=
  25  set diffmac_hostname=
  26  set /P diffmac_hostname=Enter the hostname of  the machine hosting the vtiger CRM 4.0.1:
  27  set /P diffmac_uname=Enter the vtiger CRM 4.0.1 mysql db username:
  28  set /P diffmac_password=Enter the vtiger CRM 4.0.1 mysql db password: 
  29  set /P diffmac_port=Enter the vtiger CRM 4.0.1 mysql db port: 
  30  
  31  set mysql_dir=%BINDIR%\..\mysql\bin
  32  echo mysql_dir is %mysql_dir%
  33  echo
  34  echo writing to the mysql_params.bat file
  35  echo set mysql_username=%diffmac_uname%> mysql_params.bat
  36  echo set mysql_password=%diffmac_password%>> mysql_params.bat
  37  echo set mysql_port=%diffmac_port%>> mysql_params.bat
  38  echo set mysql_hostname=%diffmac_hostname%>> mysql_params.bat
  39  echo set mysql_bundled=false>> mysql_params.bat
  40  echo set mysql_dir=%mysql_dir%>> mysql_params.bat
  41  echo
  42  rem set /P hi=bye
  43  echo set FOREIGN_KEY_CHECKS=0; > vtiger_4_2_dump.txt
  44  set mysql_dir_4_2=%BINDIR%\..\mysql\bin
  45  echo mysql_dir again is %mysql_dir_4_2%
  46  echo
  47  echo
  48  echo username is %diffmac_uname%
  49  echo password is %diffmac_password%
  50  echo port is %diffmac_port%
  51  echo hostname is %diffmac_hostname%
  52  
  53  echo about to take the dump of the 4.0.1 db and put it to vtiger_4_2_dump.txt file
  54  echo
  55  echo 
  56  "%mysql_dir_4_2%\mysqldump" --host=%diffmac_hostname% --user=%diffmac_uname% --password=%diffmac_password% --port=%diffmac_port% vtigercrm4_0_1 >> vtiger_4_2_dump.txt
  57  IF ERRORLEVEL 1 (
  58       echo "Unable to take the vtiger CRM %version% database backup. vtigercrm database may be corrupted"
  59       goto exitmigration
  60  ) 
  61  
  62  echo 4.0.1 dump taken successfully !
  63  rem set /P hi=bye
  64  echo
  65  echo
  66  echo
  67  echo
  68  call mysql_params.bat
  69  echo present directory is %cd%
  70  echo about to print the data into the migrator_connection.php file
  71  rem set /P hi=bye
  72  echo
  73      echo ^<?php > ..\apache\htdocs\vtigerCRM\migrator_connection.php
  74      echo $mysql_host_name_old = '%diffmac_hostname%'; >> ..\apache\htdocs\vtigerCRM\migrator_connection.php
  75      echo $mysql_username_old = '%diffmac_uname%'; >> ..\apache\htdocs\vtigerCRM\migrator_connection.php
  76      echo $mysql_password_old = '%diffmac_password%'; >> ..\apache\htdocs\vtigerCRM\migrator_connection.php
  77      echo $mysql_port_old = '%diffmac_port%'; >> ..\apache\htdocs\vtigerCRM\migrator_connection.php
  78      echo ?^> >> ..\apache\htdocs\vtigerCRM\migrator_connection.php
  79  rem set /P hi=bye
  80  call :echodumpstatus4diffmac
  81  goto set4_2version
  82  
  83  :samemac
  84  
  85  echo
  86  echo
  87  echo 
  88  set /p ins_dir4_0_1="Enter the vtiger CRM 4.0.1 installation bin directory (For example: C:\Program Files\vtigerCRM4_0_1\bin: "
  89  goto checkdir
  90  
  91  :findstrdir
  92  echo "4.0.1 install dir is %ins_dir4_0_1%"
  93  echo %WINDIR%
  94  set FIND_STR="%WINDIR%\system32\findstr.exe"
  95  set SLEEP_STR="%WINDIR%\system32\ping.exe"
  96  goto readMySQLparams
  97  
  98  :checkdir
  99  if NOT EXIST "%ins_dir4_0_1%\startvTiger.bat" (
 100      echo "Kindly specify a valid vtigerCRM 4.0.1 installation directory please"
 101      set ins_dir4_0_1=
 102      goto getinstalldir    
 103  )
 104  goto findstrdir
 105  
 106  :readMySQLparams
 107  echo in read mysqlparams as a result of invocation for 4.2
 108  echo present dir is %cd%
 109  echo
 110  echo
 111  rem set /P hi=bye
 112  echo Reading the vtiger CRM %version% MySQL Parameters
 113  if %version% == "4.0.1" (
 114      echo "Inside 4.0.1 loop"
 115  echo 'about to parse the startvTiger.bat of the 4.0.1 server and populate to mysql_params file
 116      %FIND_STR% /C:"set mysql_" "%ins_dir4_0_1%\startvTiger.bat" > mysql_params.bat
 117  )    
 118  if %version% == "4.2" (
 119      echo "Inside 4.2 loop"
 120  echo 'about to parse the startvTiger.bat of the 4.2 server and populate to mysql_params file
 121      %FIND_STR% /C:"set mysql_" startvTiger.bat > mysql_params.bat
 122  )    
 123  echo after writing to the mysql_params.bat file
 124  rem set /P hi=bye
 125  call mysql_params.bat
 126  
 127  echo %mysql_username%
 128  echo %mysql_password%
 129  echo %mysql_port%
 130  echo %mysql_bundled%
 131  echo %mysql_dir%
 132  
 133  
 134  rem set /P hi=bye
 135  
 136  
 137  if %version% == "4.0.1" (
 138      set /p mysql_host_name_4_0_1="Specify the host name of the vtiger CRM 4.0.1 mysql server:  "
 139  
 140      echo ^<?php > ..\apache\htdocs\vtigerCRM\migrator_connection.php
 141      echo $mysql_host_name_old = '%mysql_host_name_4_0_1%'; >> ..\apache\htdocs\vtigerCRM\migrator_connection.php
 142      echo $mysql_username_old = '%mysql_username%'; >> ..\apache\htdocs\vtigerCRM\migrator_connection.php
 143      echo $mysql_password_old = '%mysql_password%'; >> ..\apache\htdocs\vtigerCRM\migrator_connection.php
 144      echo $mysql_port_old = '%mysql_port%'; >> ..\apache\htdocs\vtigerCRM\migrator_connection.php
 145      echo ?^> >> ..\apache\htdocs\vtigerCRM\migrator_connection.php
 146  
 147  echo about to invoke isMySQLRunning
 148  goto isMySQLRunning
 149  )
 150  
 151  goto isMySQLRunning
 152  
 153  
 154  :isMySQLRunning
 155  echo MYSQLDIR=%mysql_dir%
 156  echo "Checking whether the vtiger CRM %version% MySQL server is already running"
 157  echo
 158  "%mysql_dir%\bin\mysql" --port=%mysql_port% --user=%mysql_username% --password=%mysql_password% -e "show databases" > NUL
 159  IF ERRORLEVEL 1 goto startmysql
 160  ECHO  "vtiger CRM %version% MySQL Server is already started and running"
 161  if %version% == "4.0.1" goto dump4_0_1mysql
 162  if %version% == "4.2" goto dumpin4_2mysql
 163  rem set /P hi=bye
 164  
 165  :startmysql
 166  echo "Starting %version% vtiger MySQL on port specified by the user"
 167  echo
 168  cd /D %mysql_dir%
 169  start mysqld -b .. --datadir=../data --port=%mysql_port%
 170  %SLEEP_STR% -n 11 127.0.0.1>nul
 171  "%mysql_dir%\bin\mysql" --port=%mysql_port% --user=%mysql_username% --password=%mysql_password% -e "show databases" > NUL
 172  IF ERRORLEVEL 1 goto notstarted
 173  echo "Started vtiger CRM %version% MySQL on port specified by the user"
 174  echo
 175  cd /d %VTIGER_HOME%
 176  if %version% == "4.0.1" goto dump4_0_1mysql
 177  if %version% == "4.2" goto dumpin4_2mysql
 178  
 179  :notstarted
 180  cd /d %VTIGER_HOME%
 181  echo
 182  echo
 183  ECHO "Unable to start the vtiger CRM %version% MySQL server at port %mysql_port%. Check if the port is free"
 184  echo ""
 185  echo
 186  echo
 187  echo
 188  echo
 189  set /p pt=Free the port and Press Any Key to Continue...
 190  goto startmysql
 191  
 192  :dump4_0_1mysql
 193  echo  in dump4_0_1mysql method
 194  echo
 195  echo
 196  echo set FOREIGN_KEY_CHECKS=0; > vtiger_4_2_dump.txt
 197  "%mysql_dir%\bin\mysqldump" --user=%mysql_username% --password=%mysql_password% --port=%mysql_port% vtigercrm4_0_1 >> vtiger_4_2_dump.txt
 198  IF ERRORLEVEL 1 (
 199       echo "Unable to take the vtiger CRM %version% database backup. vtigercrm database may be corrupted"
 200       goto exitmigration
 201  )
 202  echo "Data dump taken successfully in vtiger_4_2_dump.txt"
 203  
 204  goto echodumpstatus4samemac
 205  
 206  :echodumpstatus4samemac 
 207  echo
 208  echo
 209  echo
 210  echo database being created for vtigercrm4_0_1_bkp
 211  echo
 212  echo
 213  "%mysql_dir%\bin\mysql" --user=%mysql_username% --password=%mysql_password% --port=%mysql_port% -e "create database vtigercrm_4_0_1_bkp"
 214  
 215  "%mysql_dir%\bin\mysql" --user=%mysql_username% --password=%mysql_password% --port=%mysql_port% --force vtigercrm_4_0_1_bkp < vtiger_4_2_dump.txt
 216  rem set /P hi=bye
 217  echo 'about to start the input from the DataMigration.php file '
 218  echo
 219  echo
 220  ..\php\php.exe -f ..\apache\htdocs\vtigerCRM\Migrate.php
 221  echo 'exporting the migrated data to the dump file migrated_vtiger_4_0_1_dump file'
 222  
 223  echo set FOREIGN_KEY_CHECKS=0; > migrated_vtiger_4_0_1_dump.txt
 224  "%mysql_dir%\bin\mysqldump" --user=%mysql_username% --password=%mysql_password% --port=%mysql_port% vtigercrm_4_0_1_bkp >> migrated_vtiger_4_0_1_dump.txt
 225  
 226  rem set /P hi=bye
 227  echo ' about to drop the vtigercrm_4_0_1_bkp database '
 228  "%mysql_dir%\bin\mysql" --user=%mysql_username% --password=%mysql_password% --port=%mysql_port% -e "drop database vtigercrm_4_0_1_bkp"
 229  rem set /P hi=bye
 230  goto stopMySQL
 231  
 232  :stopMySQL
 233  if %mysql_bundled%==true (
 234          cd /D %mysql_dir%
 235      echo "Going to stop vtiger CRM %version% MySQL server"
 236          "%mysql_dir%\bin\mysqladmin" --port=%mysql_port% --user=%mysql_username% --password=%mysql_password% shutdown
 237          echo "vtiger CRM  MySQL Sever is shut down"
 238          cd /d %VTIGER_HOME%
 239      %SLEEP_STR% -n 11 127.0.0.1>nul
 240  )
 241  goto set4_2version
 242  
 243  
 244  
 245  
 246  
 247  
 248  
 249  
 250  
 251  
 252  
 253  
 254  
 255  
 256  
 257  
 258  
 259  
 260  
 261  :set4_2version
 262  set version="4.2"
 263  echo
 264  echo
 265  echo '######################## version set as 4.2 vtiger CRM ######################## '
 266  goto findstrdir
 267  
 268  
 269  
 270  
 271  
 272  
 273  
 274  
 275  
 276  
 277  
 278  
 279  
 280  
 281  
 282  
 283  
 284  
 285  :dumpin4_2mysql
 286  echo 'about to drop 4_2 db'
 287  "%mysql_dir%\bin\mysql" --user=%mysql_username% --password=%mysql_password% --port=%mysql_port% -e "drop database vtigercrm4_2"
 288  echo 'about create if not exists drop 4_2 db'
 289  "%mysql_dir%\bin\mysql" --user=%mysql_username% --password=%mysql_password% --port=%mysql_port% -e "create database if not exists vtigercrm4_2"
 290  echo 'about to force-dump data to the 4_2 db from the migrated_vtiger_4_0_1_dump file into the vtigercrm4_2 db'
 291  echo
 292  echo
 293  "%mysql_dir%\bin\mysql" --user=%mysql_username% --password=%mysql_password% --port=%mysql_port% vtigercrm4_2 --force < migrated_vtiger_4_0_1_dump.txt  2> migrate_log.txt
 294  IF ERRORLEVEL 1 (
 295       echo "Unable to dump data into the vtiger CRM %version% database vtigercrm4_2. Check the migrate_log.txt in the %VTIGER_HOME% directory"
 296       goto exitmigration
 297  )
 298  echo "Data successfully migrated into vtiger CRM 4.2 database"
 299  echo
 300  echo
 301  rem set /P hi=bye
 302  goto end 
 303  
 304  
 305  
 306  
 307  
 308  
 309  
 310  
 311  
 312  
 313  
 314  
 315  
 316  
 317  
 318  :exitmigration
 319  echo "Exiting Migration"
 320  goto end
 321  
 322  
 323  
 324  
 325  
 326  
 327  
 328  
 329  
 330  
 331  
 332  
 333  
 334  
 335  
 336  
 337  
 338  
 339  
 340  rem dump status for different machines
 341  
 342  :echodumpstatus4diffmac 
 343  echo
 344  echo mysql directory is %mysql_dir%
 345  "%mysql_dir%\mysql" --host=%diffmac_hostname% --user=%diffmac_uname% --password=%diffmac_password% --port=%diffmac_port% -e "create database vtigercrm_4_0_1_bkp"
 346  
 347  echo created database vtigercrm_4_0_1_bkup 
 348  
 349  "%mysql_dir%\mysql" --host=%diffmac_hostname% --user=%diffmac_uname% --password=%diffmac_password% --port=%diffmac_port% --force vtigercrm_4_0_1_bkp < vtiger_4_2_dump.txt
 350  
 351  echo dumped data from the file vtiger_4_2_dump.txt into the vtigercrm_4_0_1_bkp database
 352  
 353  echo
 354  echo
 355  echo
 356  echo 'about to start altering the database to get in sync with the 4.2 structure using the input from DataMigration.php file '
 357  echo
 358  echo present working directory is %cd%
 359  echo
 360  echo
 361  ..\php\php.exe -f ..\apache\htdocs\vtigerCRM\Migrate.php
 362  
 363  echo set FOREIGN_KEY_CHECKS=0; > migrated_vtiger_4_0_1_dump.txt
 364  
 365  "%mysql_dir%\mysqldump" --host=%diffmac_hostname% --user=%diffmac_uname% --password=%diffmac_password% --port=%diffmac_port% vtigercrm_4_0_1_bkp >> migrated_vtiger_4_0_1_dump.txt
 366  echo dumped the database to migrated_vtiger_4_0_1_dump.txt file
 367  
 368  rem set /P hi=bye
 369  echo
 370  echo
 371  echo
 372  echo
 373  echo ' about to drop the vtigercrm_4_0_1_bkp database '
 374  "%mysql_dir%\mysql" --host=%diffmac_hostname% --user=%diffmac_uname% --password=%diffmac_password% --port=%diffmac_port% -e "drop database vtigercrm_4_0_1_bkp"
 375  
 376  goto end
 377  
 378  
 379  :end
 380  del mysql_params.bat
 381  rem exit


Généré le : Sun Feb 25 10:22:19 2007 par Balluche grâce à PHPXref 0.7