edwardsmarkf/server-migration
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
############################################################ # # # n e w s e r v e r i n i t i a l i z a t i o n # # # ############################################################ 00) echo "export KVM_NAME=THIS-SERVER-NAME-CHANGE-THIS-PLEASE-TO-NEW-SERVER-NAME;" > /etc/profile.d/kvmName.sh; ## 2026-02-20 1) (this step takes about 3.5 hours or 210 minutes!) dnf --assumeyes install time ; cat <<END | cd ; dnf --assumeyes update ; dnf --assumeyes upgrade ; dnf clean all ; dnf --assumeyes install time ; dnf --assumeyes install git && git clone https://github.com/edwardsmarkf/server-migration ; cd ~/server-migration/ ; time bash -vx ~/server-migration/Master_Installer.bsh > ~/server-migration/Master_Installer.bsh.log 2>&1 ; END nohup time bash -vx - > ~/do-all-the-work.bsh.log 2>&1 & ##################################################################### # # # c u r r e n t s e r v e r d a t a e x t r a c t i o n # # # ##################################################################### 2) on CURRENT server: (NOTE LENGTH OF TIME!!) git clone https://github.com/edwardsmarkf/server-migration ; find . -name mariadbDumpAllDatabases.bsh ; ## optional vi ./server-migration/mariadb/migration/mariadbDumpAllDatabases.bsh ; ## change password (or use sed) ## --or-- ## CHANGE THE HARDCODED PASSWORD ! sed --in-place --expression='s/CHANGE-THIS/password/;' ./server-migration/mariadb/migration/mariadbDumpAllDatabases.bsh ; cat <<END_OF_CURRENT_SERVER | bash -vx ./server-migration/mariadb/migration/mariadbDumpAllDatabases.bsh ; ## on OLD server! ls -lh /home/mark ; ## confirm 63 megabyte size for mariadb-database-tar.gz crontab -l > /home/mark/crontab.txt ; gzip /home/mark/crontab.txt ; ## on OLD server! tar --create --gunzip --file=/home/mark/usr_local_bash.tar.gz /usr/local/bash/ ; ## on OLD server! tar --create --gunzip --file=/home/mark/usr_local_lib_php.tar.gz /usr/local/lib/php/ ; ## on OLD server! tar --create --gunzip --file=/home/mark/letsencrypt.tar.gz /etc/letsencrypt ; ## on OLD server! tar --create --gunzip --file=/home/mark/home.tar.gz /home/ ; ## 34 gig! on OLD server! END_OF_CURRENT_SERVER nohup time bash -vx - > ./current-server-tar-gz-creates.log 2>&1 & ## detach ######################################################## # # # f e t c h d a t a t o n e w s e r v e r # # # ######################################################## on new server: (30 minutes) 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! sftp> ls -lh ## human readable file size sftp> mget *.gz ## fetch the gzips sftp> !ls -lh ## file sizes on NEW server (notice bang character) sftp> rm *.gz ## can be done in the sftp session! or..... rm -Rf /home/mark/crontab.txt.gz /home/mark/*.tar.gz /home/mark/*.sql.gz ; ## on OLD server! ###################################################################### # # # m o v e d a t a t o p r o p e r l o c a t i o n s # # # ###################################################################### # also on the new server: gzip --decompress *.gz ; ### you MAY run into space issues on the new server! tar -xf ./home.tar ; tar -xf ./letsencrypt.tar ; tar -xf ./mariadb-databases.tar ; tar -xf ./usr_local_bash.tar ; tar -xf ./usr_local_lib_php.tar ; rm ./home.tar ; # we MAY need this for space! ##### NEW CLONE MADE ! so start here... mv --verbose /home/ /home-RENAMED/ ; mv --verbose .//home/ /home/ ; rsync --verbose --archive /home-RENAMED/ /home/ ; ## check file owners ## letsencrypt stuff rsync --verbose --archive ./etc/letsencrypt/ /etc/letsencrypt/ ; mv --verbose .//usr/local/bash/ /usr/local/ ; mv --verbose .//usr/local/lib/php/ /usr/local/lib/ ; cat ./crontab.txt | crontab - ; # quick way to load crontab from old server! ################################################### # # # m a r i a d b d a t a i n s t a l l # # # ################################################### ## the childs last name (lowercase) and the childs first name (camelCase) and the special one from 1974-1991 (camelCamelCase) no spaces sed --in-place --expression="s/^password=''/password='CHANGE-THIS'/" ~/server-migration/mariadb/migration/create_db_and_users.bsh ; ## edit and add password! bash - ~/server-migration/mariadb/migration/create_db_and_users.bsh > ./create_db_and_users.sql ; mariadb < ./create_db_and_users.sql ; bash ~/server-migration/mariadb/migration/create_db_and_users.bsh \ | grep TEMP_SQL_LOCATION \ | sed -e 's/.* ### //; s/ ## //;1i TEMP_SQL_LOCATION=/tmp/old_server_data/tmp/mariadb-tmp/;' \ > load_sql_tables.bsh \ ; ## create the 'load' script! find . -name '*.sql' ; ## get directory name for new `load_sql_tables.bsh` and manually add it! bash -vx load_sql_tables.bsh > load_sql_tables.bsh.log 2>&1 ; ## run the newly created bash script approx 30 minutes run time du --summarize --human-readable /var/lib/mysql/ ; ## check for total size mariadb-secure-installation; ## IMPORTANT! ### ? ? ? ? npm install uuid@latest ; ### ? ? ? ? ? https://stackoverflow.com/questions/68170853/npm-warn-deprecated-uuid3-4-0-please-upgrade-to-version-7-or-higher bash -vx ~/server-migration/node/pm2-initialize.bsh > ~/server-migration/node/pm2-initialize.bsh.log 2>&1 ; ####################################################### # # # s - n a i l - p o s t f i x . b s h # # # ####################################################### ## get password from google and alter /usr/local/bash/serverUtilitzation because serverUtilization.bsh uses 'Content-type: type/html' bash -vx ~/server-migration/s-nail/s-nail-postfix.bsh ~/server-migration/s-nail/s-nail-postfix.bsh.log 2>&1 ; ########################## # # # r s y n c # # # ########################## ## TEST rsync FIRST !! sshpass -p 'PASSWORD' sftp -o StrictHostKeyChecking=no mark@162.220.165.228 ; ## test to make sure this works! # format: rsync SOURCE DESTINATION sshpass -p 'PASSWoRd' \ sudo --user=comptonpeslonline.com rsync --verbose --archive --rsh='ssh -o StrictHostKeyChecking=no' \ /home/comptonpeslonline.com/public_html/comptonPractice/user-recorded-audio-files/ \ comptonpeslonline.com@162.220.165.228:/home/comptonpeslonline.com/public_html/comptonPractice/user-recorded-audio-files/ ; sshpass -p 'PASSWoRd' \ sudo --user=comptonpeslonline.com rsync --verbose --archive --rsh='ssh -o StrictHostKeyChecking=no' \ 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/ ; sshpass -p 'PASSWoRd' \ sudo --user=comptonpeslonline.com rsync --verbose --archive --rsh='ssh -o StrictHostKeyChecking=no' \ comptonpeslonline.com@162.220.165.228:/home/comptonpeslonline.com/public_html/voicefiles/ \ /home/comptonpeslonline.com/public_html/comptonPractice/voicefiles/ ; ## misc php archive files: rsync --verbose --archive --rsh=ssh /usr/local/lib/php/ root@199.231.184.26:/usr/local/lib/php/ ################################## # # # f i n a l t e s t i n g # # # ################################## find /home/ -type f -name '*.php' -exec php -l {} \; > php-lint-test.txt 2> php-lint-test-errors.txt ; ## php lint test ls -lR /home/comptonpeslonline.com/ | grep -u "comptonpeslonline.com:comptonpeslonline.com" ; ## double-check correct ownership! 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/ ## mkdir --verbose /usr/local/bash/ ; ## mkdir --verbose /usr/local/lib/php/ ; manually add/edit these to /etc/httpd/conf/httpd.conf: (carouselhouse.com still shows in the OLD httpd.conf, so we ignore it) 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 apachectl configtest ; apachectl restart ; cp --verbose /etc/httpd/conf/httpd.conf ./httpd.conf ; sed --in-place --file=- ./httpd.conf <<END_OF_GENERIC_SED ; s?^ SSLCertificateFile /? #### &?; s?^ SSLCertificateKeyFile /? #### &?; END_OF_GENERIC_SED sed --file=- ./httpd.conf <<END_OF_ACCENTREDUCTION_ONLINE_SED > x.x ; /RewriteRule .*well-known).* https:\/\/accentreduction.online:10000\//,/VirtualHost/{/#SSLCertificateKeyFile/a \ ####\n\ SSLCertificateFile /home/accentreduction.online/ssl.cert\n\ SSLCertificateKeyFile /home/accentreduction.online/ssl.key } END_OF_ACCENTREDUCTION_ONLINE_SED sed --file=- ./httpd.conf <<END_OF_AJCOMPTONPESL_COM_SED > x.x ; /RewriteRule .*well-known).* https:\/\/ajcomptonpesl.com:10000\//,/VirtualHost/{/#SSLCertificateKeyFile/a \ ####\n\ SSLCertificateFile /home/ajcomptonpesl.com/ssl.cert\n\ SSLCertificateKeyFile /home/ajcomptonpesl.com/ssl.key } END_OF_AJCOMPTONPESL_COM_SED sed --file=- ./httpd.conf <<END_OF_COMPTONPESLONLINE_COM_SED > x.x ; /RewriteRule .*well-known).* https:\/\/comptonpeslonline.com:10000\//,/VirtualHost/{/#SSLCertificateKeyFile/a \ ####\n\ SSLCertificateFile /home/comptonpeslonline.com/ssl.cert\n\ SSLCertificateKeyFile /home/comptonpeslonline.com/ssl.key } END_OF_COMPTONPESLONLINE_COM_SED sed --file=- ./httpd.conf <<END_OF_COMPTONPESLONLINE_INFO_SED > x.x ; /RewriteRule .*well-known).* https:\/\/comptonpeslonline.info:10000\//,/VirtualHost/{/#SSLCertificateKeyFile/a \ ####\n\ SSLCertificateFile /home/comptonpeslonline.info/ssl.cert\n\ SSLCertificateKeyFile /home/comptonpeslonline.info/ssl.key } END_OF_COMPTONPESLONLINE_INFO_SED sed --file=- ./httpd.conf <<END_OF_EDWARDSMARK_COM_SED > x.x ; /RewriteRule .*well-known).* https:\/\/edwardsmark.com:10000\//,/VirtualHost/{/#SSLCertificateKeyFile/a \ ####\n\ SSLCertificateFile /home/edwardsmark.com/ssl.cert\n\ SSLCertificateKeyFile /home/edwardsmark.com/ssl.key } END_OF_EDWARDSMARK_COM_SED sed --file=- ./httpd.conf <<END_OF_ENGLISHWITHOUTACCENT_COM_SED > x.x ; /RewriteRule .*well-known).* https:\/\/englishwithoutaccent.com:10000\//,/VirtualHost/{/#SSLCertificateKeyFile/a \ ####\n\ SSLCertificateFile /home/englishwithoutaccent.com/ssl.cert\n\ SSLCertificateKeyFile /home/englishwithoutaccent.com/ssl.key } END_OF_ENGLISHWITHOUTACCENT_COM_SED sed --file=- ./httpd.conf <<END_OF_GORDONREDWARDS_COM_SED > x.x ; /RewriteRule .*well-known).* https:\/\/gordonredwards.com:10000\//,/VirtualHost/{/#SSLCertificateKeyFile/a \ ####\n\ SSLCertificateFile /home/gordonredwards.com/ssl.cert\n\ SSLCertificateKeyFile /home/gordonredwards.com/ssl.key } END_OF_GORDONREDWARDS_COM_SED sed --file=- ./httpd.conf <<END_OF_SLRH_ORG_SED > x.x ; /RewriteRule .*well-known).* https:\/\/slrh.org:10000\//,/VirtualHost/{ /SSLCertificateKeyFile \/etc\/ssl\/virtualmin\//a \ ####\n\ SSLCertificateFile /home/slrh.org/ssl.cert\n\ SSLCertificateKeyFile /home/slrh.org/ssl.key } END_OF_SLRH_ORG_SED