
! intead see /var/www/html/groovix/common/doc/customer-server-moving-to-new-server.txt

#######################################
NEW: start with deb+installer
# grab util
wget -O groovix-util.deb http://archive6.groovix.net/groovix-util.deb
dpkg -i groovix-util.deb
apt-get -f install
groovix-sources-setup
apt-get install groovix-server
groovix-server-install

NEWSERVER=10.1.75.251
OLDSERVER=10.1.75.250

mkdir -p /var/backups/groovix/groovix-snapshots/
rsync -a $OLDSERVER:/var/backups/groovix/groovix-snapshots/last/ /var/backups/groovix/groovix-snapshots/old-server/

edit /etc/cron.d/groovix-server-custom to include all special stuff that was on the old server

edit /etc/hosts to have fqdn : 127.0.1.1  CUSTCODE.groovix.net  groovix-server.lan  groovix-server localhost.localdomain 

cp -rp /var/backups/groovix/groovix-snapshots/old-server/root/.ssh/id_rsa* /root/.ssh/

#######################################


#######################################
#######################################
#######################################

#######################################
#old
#######################################

NEWSERVER=10.1.75.251
OLDSERVER=10.1.75.250

on new server:
#pre 1604# apt-get install mysql-server  php5-mysql python-mysqldb libapache2-mod-php5 php5 php5-mysql apache2 python-httplib2
apt-get install mysql-server  php-mysql python-mysqldb libapache2-mod-php php php-mysql apache2 python-httplib2

apt-get install mysql-server 
apt-get install php-mysql python-mysqldb
apt-get install libapache2-mod-php php php5-mysql
apt-get install apache2
apt-get install python-httplib2


get these moved over to new server:

/var/www/groovix/
/var/www/index.html
/etc/groovix
  - especially /etc/groovix/

######################################################################
#make backups for future reference:
mkdir -p /backup/old-server/var/lib
rsync -a root@$OLDSERVER:/root/ /backup/old-server/root/
rsync -a root@$OLDSERVER:/etc/ /backup/old-server/etc/
rsync -a root@$OLDSERVER:/var/www/ /backup/old-server/var/www/
rsync -a root@$OLDSERVER:/var/lib/mysql/ /backup/old-server/var/lib/mysql/

#actually put files into place, if bandwidth is an issue sync from /backup instead of from remote server again
#rsync -a /backup/old-server/var/www/groovix/ /var/www/groovix/
#rsync -a /backup/old-server/etc/groovix/ /etc/groovix/
#rsync -a /backup/old-server/var/lib/mysql/gxdb_mead /var/lib/mysql

rsync -a root@$OLDSERVER:/etc/groovix/ /etc/groovix/
rsync -a root@$OLDSERVER:/var/www/groovix/ /var/www/groovix/
#will do this later - mysql must be stopped# rsync -a root@$OLDSERVER:/var/lib/mysql/DBNAME_HERE/ /backup/old-server/var/lib/mysql/DBNAME_HERE/

#if using apt-mirror and not transfering hard drive  -  make sure you put in correct dir, i.e. /home/ vs. /var/
#rsync -a $OLDSERVER:/var/spool/apt-mirror/ /var/spool/apt-mirror/mirror/
###############################################################################################

edit /etc/hosts to have fqdn : 127.0.1.1  CUSTCODE.groovix.net  groovix-server.lan  groovix-server localhost.localdomain 

edit /etc/apache2/sites-available/default , take all entries including /var/www/groovix over

restart apache

#start regular groovix install process up through pactime - gets users and dbs created
OR __ use this method __ :

#ON OLD SERVER:
mygrants()
{
  mysql -B -N $@ -e "SELECT DISTINCT CONCAT(
    'SHOW GRANTS FOR \'', user, '\'@\'', host, '\';'
    ) AS query FROM mysql.user" | \
  mysql $@ | \
  sed 's/\(GRANT .*\)/\1;/;s/^\(Grants for .*\)/## \1 ##/;/##/{x;p;x;}'
}
mygrants --user=root -p > /tmp/grants.txt
# need to enter password twice or include it in command
reset
and look for the important users like gxu_mead (NOT root) , there should be 2 or lines for each user, paste them into mysql on new server

on new server run 
mysql -u root -p 
CREATE USER 'gvu_pcpls'@'localhost' IDENTIFIED BY 'yourpassword';
and paste them in

#will look something like this, if necessary reconstruct from scratch, change password for the user afterwards:
## Grants for gxu_scls@% ##
#shouldnt need# GRANT USAGE ON *.* TO 'gxu_scls'@'%';

GRANT USAGE ON *.* TO 'gxu_scls'@'localhost' IDENTIFIED BY PASSWORD '*CF46A4539321525DA5440DF6CEA65F3D6E96B172';
GRANT ALL PRIVILEGES ON `gxdb_scls`.* TO 'gxu_scls'@'localhost';




stop mysql on both servers
NOTE: this will get all the myisam tables but maps ( and pactime_config?) uses innodb for some reason : data is in ibdata1 file but can't just copy it over - use mysqldump on maps instead OR
	- can convert: 
ALTER TABLE maps ENGINE=MyISAM;
ALTER TABLE pactime_config ENGINE=MyISAM;
ALTER TABLE gxrelease_jobs ENGINE=MyISAM;
ALTER TABLE gxrelease_jobs_old ENGINE=MyISAM;
ALTER TABLE gxrelease_txlog ENGINE=MyISAM;

	- switched new installs to use myisam for maps, not sure if it will cause problems
rsync -a $OLDSERVER:/var/lib/mysql/gvdb_lcplin/ /var/lib/mysql/gvdb_lcplin/
chown -R mysql.mysql /var/lib//mysql/gxdb_scls/

start mysql on both servers

#must import timzezone or some groovix functions like guest passes wont work
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql --user=root -p mysql


to keep old ssh keys 
#scp /root/.ssh/id_dsa* root@$NEWSERVER:/root/.ssh/
scp root@$OLDSERVER:/root/.ssh/id_dsa* /root/.ssh/

#NOTE: in 16.04 dsa doesn't work - need to ssh-keygen to create rsa key and use gnc to distribute that to all machines


edit /etc/crontab to include all special stuff that was on the old server




see /var/www/groovix/common/doc/groovix-server-installation-from-scratch.txt
need to get everything into apache sites-available/default




************ important ! *****************************
for ubuntu 14.04 need: 
- make sure document root is /var/www not /var/www/html

************ important ! *****************************
for ubuntu 14.04 need to run:
a2enmod cgi
service apache2 restart

if 16.04, need to use mysqli as database type for pacrez, set 
db_type: mysqli
in pacrez/includes/settings.php
also change mysql_num_rows to mysqi_num_rows in pacrez/includes/pacrez_functions.php

in 16.04, need to change to NewADOConnection('mysqli');  in:
/var/www/groovix/cmon/includes/connections.php /var/www/groovix/cmon/list.php /var/www/groovix/cmon/details.php /var/www/groovix/cmon/status.php

in 16.04 need to change mysql_fetch_row to mysqli_fetch_row
/var/www/groovix/pacrez/includes/pacrez_functions.php

on 16.04:
in all instances of my_db.py add or change to:
self.connection.autocommit(True)

on 16.04 don't know why but had to change pacrez/python/pacrez_lib.py 
ooo=db.dbexecfetch("SELECT * FROM status WHERE workstation= %s AND parameter='state' AND value LIKE '%%cur=out_of_order%%' ",label) ;
#to
ooo=db.dbexecfetch("SELECT * FROM status WHERE workstation='"+label+"' AND parameter='state' AND value LIKE '%%cur=out_of_order%%' ") ;

blank cmon page ( break error):
root@netsvcs1:~# cp /var/www/groovix-server-components-2016-07-25/groovix/cmon/classes/adodb/adodb-time.inc.php /var/www/groovix/cmon/classes/adodb/adodb-time.inc.php 
root@netsvcs1:~# cp /var/www/groovix-server-components-2016-07-25/groovix/cmon/js/scriptaculous.js /var/www/groovix/cmon/js/scriptaculous.js

if using pacrez, will need pacauth:
chown www-data.www-data /etc/groovix/pacauth.conf ; # so pacrez can read it
# if 64-bit server use 32-bit groovix packages
vi /etc/apt/sources.list.d/groovix.list
#deb [arch=i386] http://archive5.groovix.net/ubuntu precise main
deb  http://archive6.groovix.net/ubuntu noble main

apt-get update
apt-get install groovix-util groovix-pacauth

#if necessary wget from archive5.groovix.net/ubuntu/pool/main/g/groovix-pacauth/groovix-pacauth_2013.0042_all.deb and dpkg -i

cd /tmp
wget http://s2.groovix.net/tmp/groovix-server-bin.tgz
tar xfvz groovix-server-bin.tgz
cp groovix-server-bin/* /usr/bin/


apt-get install wakeonlan

apt-get install apt-mirror

IF SERVER IS 64-BIT: in mirror.list must set 
set defaultarch  i386


cp /etc/apt/mirror.list /etc/apt/mirror.list.defaults
cp /backup/old-server/etc/apt/mirror.list /etc/apt/mirror.list






