Skip to content

edwardsmarkf/server-migration

Repository files navigation

#### initial setup


00)    echo "export KVM_NAME=THIS-SERVER-NAME-CHANGE-THIS-PLEASE-TO-NEW-SERVER-NAME" > /etc/profile.d/kvmName.sh;   ## 2026-02-20

1)  
                            ######cat  <<END    >  ~/do-all-the-work.bsh   ;
   cat  <<END   |
   cd                                                                                                                    ; 
   dnf --assumeyes update                                                                                                ; 
   dnf  --assumeyes upgrade                                                                                              ;
   dnf   clean all                                                                                                       ;
   dnf  --assumeyes  install git  && git clone  https://github.com/edwardsmarkf/server-migration                         ;
   cd  ~/server-migration                                                                                                ;
   bash -vx    ~/server-migration/Master_Installer.bsh   >   ~/server-migration/Master_Installer.bsh.log   2>&1          ;
END
nohup   bash -vx  -   >  ~/do-all-the-work.bsh.log  2>&1  &


    ####  ????this has to run in the FOREGROUND because of webmin!

2) 

cat  >  ./mariadbDumpAllDatabases.bsh  ;   ## get from  server-migration/mariadb/mariadbDumpAllDatabases.bsh

crontab  -l         >  /home/mark/crontab.txt  ;  gzip  /home/mark/crontab.txt                           ;   ## on OLD server!
tar --create --gunzip --verbose  --file=/home/mark/usr_local_bash.tar.gz      /usr/local/bash/           ;   ## on OLD server! 
tar --create --gunzip --verbose  --file=/home/mark/usr_local_lib_php.tar.gz   /usr/local/lib/php/        ;   ## on OLD server!
tar --create --gunzip --verbose  --file=/home/mark/letsencrypt.tar.gz         /etc/letsencrypt           ;   ## on OLD server!
tar --create --gunzip            --file=/home/mark/home.tar.gz                /home/                     ;   ##  33.7 gig!  on OLD server!
bash -vx           ./mariadbDumpAllDatabases.bsh  ;  mv  --verbose  /tmp/*.sql.gz   /home/mark/    ;   ## on OLD server!


on new server:

dnf  --assumeyes  install sshpass  ;   

mkdir  /tmp/old_server_data && cd  $_  ;
##   get IP number from NEW server and temporarily add it to old server csf firewall  port 22   ##
                                                ###  https://stackoverflow.com/questions/28461713/how-to-ignore-or-pass-yes-when-the-authenticity-of-host-cant-be-established-i
sshpass -p  'MY-PASSWORD-FOR-ACCT-MARK'   sftp  -o StrictHostKeyChecking=no   mark@162.220.165.228  ;   ## grab stuff from OLD server!
   ##  ls -lh  ;  human readable file size

## on old server!
rm -Rf  /home/mark/crontab.txt.gz  /home/mark/*.tar.gz   /home/mark/*.sql.gz  ;  ## on OLD server!

on new server!

      ## the childs last name (lowercase) and the childs first name (camelCase) and the special one from 1974-1991 (camelCamelCase) no spaces
bash -vx  ~/server-migration/mariadb/migration/create_db_and_users.bsh    ;  ## edit and add password!

                                                   ## mkdir  --verbose  /usr/local/bash/      ;
                                                   ## mkdir  --verbose  /usr/local/lib/php/   ;
gzip --decompress  *.gz  ;     ### you MAY run into space issues on the new server!
tar -xf  *.tar           ;

mv  --verbose  /tmp/old_server_data/usr/local/bash/              /usr/local/               ;
mv  --verbose  /tmp/old_server_data/usr/local/lib/php/           /usr/local/lib/           ;
mv  --verbose  /home/                                            /home-RENAMED/            ;
mv  --verbose  /tmp/old_server_data/home/                        /home/                    ;

    ##  letsencrypt stuff
mv  --verbose  /tmp/old_server_data/etc/letsencrypt/live/       /etc/letsencrypt/live/     ;
mv  --verbose  /tmp/old_server_data/etc/letsencrypt/archive/    /etc/letsencrypt/archive/  ;
mv  --verbose  /tmp/old_server_data/etc/letsencrypt/csr/        /etc/letsencrypt/csr/      ;
mv  --verbose  /tmp/old_server_data/etc/letsencrypt/keys/       /etc/letsencrypt/keys/     ;
mv  --verbose  /tmp/old_server_data/etc/letsencrypt/renewal/*   /etc/letsencrypt/renewal/  ;

bash -vx  ~/server-migration/node/pm2-install.bsh                 >  ~/server-migration/node/pm2-install.bsh.log   2>&1  ;


cat ./crontab.txt  |  crontab   -   ;   #



manually add/edit these to  /etc/httpd/conf/httpd.conf:

    SSLCertificateFile /home/accentreduction.online/ssl.cert
    SSLCertificateKeyFile /home/accentreduction.online/ssl.key
    SSLCertificateChainFile /home/accentreduction.online/ssl.ca

    SSLCertificateFile /home/ajcomptonpesl.com/ssl.cert
    SSLCertificateKeyFile /home/ajcomptonpesl.com/ssl.key
    SSLCertificateChainFile /home/ajcomptonpesl.com/ssl.ca

    SSLCertificateFile /home/comptonpeslonline.com/ssl.cert
    SSLCertificateKeyFile /home/comptonpeslonline.com/ssl.key
    SSLCertificateChainFile /home/comptonpeslonline.com/ssl.ca

    SSLCertificateFile /home/comptonpeslonline.info/ssl.cert
    SSLCertificateKeyFile /home/comptonpeslonline.info/ssl.key
    SSLCertificateChainFile /home/comptonpeslonline.info/ssl.ca

    SSLCertificateFile /home/edwardsmark.com/ssl.cert
    SSLCertificateKeyFile /home/edwardsmark.com/ssl.key
    SSLCertificateChainFile /home/edwardsmark.com/ssl.ca

    SSLCertificateFile /home/englishwithoutaccent.com/ssl.cert
    SSLCertificateKeyFile /home/englishwithoutaccent.com/ssl.key
    SSLCertificateChainFile /home/englishwithoutaccent.com/ssl.ca

    SSLCertificateFile /home/gordonredwards.com/ssl.cert
    SSLCertificateKeyFile /home/gordonredwards.com/ssl.key
    SSLCertificateChainFile /home/gordonredwards.com/ssl.ca

    SSLCertificateFile /home/slrh.org/ssl.cert
    SSLCertificateKeyFile /home/slrh.org/ssl.key
    
   ????????????????  below ?????

    SSLCertificateFile /etc/letsencrypt/live/carouselhouse.com/cert.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/carouselhouse.com/privkey.pem
    SSLCertificateChainFile /etc/letsencrypt/live/carouselhouse.com/fullchain.pem

    SSLCertificateFile /home/comptonpeslonline.info/ssl.cert
    SSLCertificateKeyFile /home/comptonpeslonline.info/ssl.key
    SSLCertificateChainFile /home/comptonpeslonline.info/ssl.ca

    












3)  virtualmin
            #######################3)  webmin/virtualmin/csf 
            #######################      now need to download and ftp the install file from the website login-area rather than trying to curl it from inside the script

###    ???????  use "--disableplugin subscription-manager" instead   
##           sed --in-place  --expression='s/enabled=1/enabled=0/;' /etc/yum/pluginconf.d/product-id.conf ;  ## 2025-07-29 

4)  bash -vx   ./bash-misc/dnf-yum.bsh     > ./bash-misc/dnf-yum.bsh.log     2>&1   ;
5)  bash -vx   ./bash-misc/root-init.bsh   > ./bash-misc/root-init.bsh.log   2>&1   ;

6)  ### ????  sed --in-place  --expression='s/enabled=1/enabled=0/;' /etc/yum/pluginconf.d/product-id.conf ;  ## 2025-07-29 for RL-10

7)  ffmpeg (can probably be done anytime but TEST first before starting!)

#)  SKIP SKIP  Mariadb UPGRADE (LET VIRTUALMIN INSTALL PHP, let github install PERL  ## do before perl and php)

8)  php and  /php/phpImageMagick.bsh

9)  perl/CPAN


09)  clamav

20) ./bash-misc/mailx-postfix.bsh

40)  bash -vx  ./node/bash-js.bsh ;

41)  httpd.conf/apache.bsh  -- not quite ready to run manually do it

42)  contact STRIPE.COM  and let them know the new IP ## on the callback hook for ajcomptonpesl.com
                        https://www.edwardsmark.com/textpattern/articles/265/associate-stripe-api-key-with-specific-ip-number
42)   /usr/bin/bash  - tar over

50) crontab-reboot-commands

60) fail2ban-client  --version ;  # make sure faile2ban-client is installed!  Fail2Ban v0.11.2 at of 2012-07-22

70) install ./bash-misc/certbot

80) visudo  for node processes

90) copy over all crontab jobs

95) bash -vx  /node/pm2.bsh  ;

100)   edit  /etc/hostname and include 'edwardsmark.info'


## new 2016-02-28   -- THIS IS COPIED IN WHEN DIRECTORY IS MOVED!
mkdir        --verbose                              /home/comptonpeslonline.com/tmpVoiceSpiceFile/   ;
chmod  755   --verbose                              /home/comptonpeslonline.com/tmpVoiceSpiceFile/   ;
chown  comptonpeslonline.com:comptonpeslonline.com  /home/comptonpeslonline.com/tmpVoiceSpiceFile/   ;



#  rsync  SOURCE     DESTINATION
sudo  -u  comptonpeslonline.com  rsync --verbose --archive  --rsh=ssh                                                                                            \
                                    comptonpeslonline.com@162.220.165.228:/home/comptonpeslonline.com/public_html/comptonPractice/user-recorded-audio-files/     \
                                    /home/comptonpeslonline.com/public_html/comptonPractice/user-recorded-audio-files/                                           ;

sudo  -u  comptonpeslonline.com  rsync --verbose --archive  --rsh=ssh                                                                                            \
                                    comptonpeslonline.com@162.220.165.228:/home/comptonpeslonline.com/public_html/voicefiles/                                    \
                                    /home/comptonpeslonline.com/public_html/comptonPractice/voicefiles/                                                          ;
## one line no passord prompting:
sshpass -p  'PASSWORD'                                                                                                                                           \
            sudo  --user=comptonpeslonline.com  rsync --verbose --archive  --rsh=ssh                                                                             \
                        comptonpeslonline.com@162.220.165.228:/home/comptonpeslonline.com/public_html/voicefiles/                                                \
                        /home/comptonpeslonline.com/public_html/voicefiles/                                                                                      ;


## important misc php archive files:
 rsync --verbose --archive  --rsh=ssh  /usr/local/lib/php/   root@199.231.184.26:/usr/local/lib/php/




######### ftp   -  START OUT WITH A WORKING DOMAIN NAME   (2013-07-03)
#####################https://www.digitalocean.com/community/articles/how-to-set-up-proftpd-on-centos-6
moved to  sftp.bsh  February 2019

rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm  ;
yum   install  ftp ;
yum  install   proftpd ;
hostname   edwardsmark.com  ;
echo  <<END   >> /etc/hosts   ;
199.231.184.26   server
END
sed -i  -e  "s/ServerName  whatever/ServerName myNewDomainName.com"  /etc/proftpd  ;
service proftpd restart   ;
##mkdir  /home/mark ;
useradd  mark ;
passwd  mark ;
ftp  myNewDomainName.com  ;   ## test login
sftp mark@127.0.0.1 ; ## 2016-02-09- notice sftp since regular ftp may not be an option anymore.



## 2019-11-13 - ran on centos-7/8 successfully.




 chkconfig dovecot off  ;   ### disable dovecot from starting


2013-03-01  -- to supress messages from emailing:
echo "/usr/bin/php-cgi"   >>  /etc/csf/csf.pignore  ;

## written from    http://configserver.com/free/csf/install.txt



/etc/resolv.conf :
nameserver 66.45.228.250
nameserver 8.8.8.8
nameserver 127.0.0.1

####  https://www.interserver.net/forum/threads/strange-error-message-sending-email-on-kvm275.20548/
  # I use
  # nameserver 69.10.54.252
  # nameserver 66.45.251.218
  # nameserver 64.20.34.50
  # nameserver 66.45.228.250
  # nameserver 1.1.1.1
  # nameserver 8.8.8.8




(php pear???  do we need it ???)


====  bcc mail

to always bcc mail:  (2014-10-17)

/etc/postfix/main.cf  -- add this line:
always_bcc = edwardsmarkf@gmail.com




====  httpd.conf

add this:

    AddType audio/ogg .ogg .ogv
    AddType audio/speex .spx



systemctl   start   mariadb;    ## replacement for mysql  2015-12-18






below stuff may be obsolete:




## 2014-01-05 added by mark - test to make sure that mysql started, if not, remove
##              the sock file and try again
if  [  $(/etc/init.d/mysqld status  |  grep  'mysqld (pid .*) is running'  |  wc --lines) -gt 0 ];
then
        echo 'mysql successfully started -- no action taken';
else
        echo $0 'mysql did *NOT* start successfully -- removing the sock and restarting.....';
        [ -e /var/lib/mysql/mysql.sock ] && rm /var/lib/mysql/mysql.sock;
        /etc/init.d/mysqld start;
        /bin/mail -v -r info@edwardsmarkf.info -s 'mysql start failure notice' mark@edwardsmark.com  <<END
        $(/bin/date)
        $0 mysql did not start on reboot -- removing sock and trying again
        please see  /var/log/boot.log file for more details
END
fi;



=================================

====   (OBSOLETE
 ftp auto-login:  (2013-05-10)
echo 'machine ftp.adrive.com   login  mark@edwardsmark.com  password JABBERWOLKY'    >>  ~/.netrc ;
chmod 600    ~/.netrc ;
=== 


=== two ways to manage dns records ===============

A: using interserver name server
1) log into the my.interserver.net control panel
2) Domains---->DNS-Manager   (domains is next to "home" second from left)
3) "Add New DNS Entry" - enter clients domain name and interserver.net ip address 69.10.48.25
4) click on the little wrench on the far right
5) create 5 new mx records 

B: using our own customized name server and virtualmin:
1) create ns1/2.XXXX.com subdomains and point "A" records to 69.10.48.25
2) use nameserver from step one for given domain
3) log into virtualmin and select(or create) new virtual-server (new website)
4) ServerConfiguration--->DNS_Records
5) enter 5 new mx records using "Create Record of Type" button at bottom (be sure to select MX)


======== authorized dns ===================
Primary DNS - cdns1.interserver.net 209.159.155.28
Secondary DNS - cdns2.interserver.net 66.45.228.248




OBSOLETE

## flvar admin files  -   THIS MIGHT NOT WORK PROPERLY......
rsync --verbose --archive  --rsh=ssh  /usr/share/red5/webapps/   root@199.231.184.26:/usr/share/red5/webapps/

==== /etc/init.d/rc.local: (2014-11-02)

mount -a ;                      ##   2013-05-14 mounts up the stuff in the fstab file
/etc/init.d/red5  start   >/usr/share/red5/red5.log  2>&1       





####  ## ddos-deflate installation  2016-04-20
####  wget http://www.inetbase.com/scripts/ddos/install.sh
####  chmod 0700 install.sh
####  ./install.sh


####    ## dont forget jQuery ! (?)
####     rsync --verbose --archive  --rsh=ssh  /usr/local/jquery/   root@edwardsmarkf.info:/usr/local/jquery/


About

marks server migration

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages