Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Configuration and data Migration Scheme of Linux Server

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

problem

Migrate the configuration and data of the Linux functional server to the new server

Solution

The method of migrating a Linux server with master + function

Requirement 1: new and old servers are installed with the same version of Prim@Hosting (the most complete virtual host management system)

Requirement 2: the following examples assume that bash is used as the shell

In this method, all data and configuration can be recovered without detection and repair from the main control. Except for disk quota restrictions

If you need to reset the disk quota limit, perform the detection and repair of the web site from the master after the recovery, and select the "Update normal site at the same time" option.

[note] Please read the whole content carefully and understand what needs to be done before you can really get started.

On the old server:

The following assumes that the backup directory is: / backup

1. Backing up web data

Cd / www/

Tar zcpf / backup/users.tar.gz users

two。 Back up mail data

Cd / var

Tar zcpf / backup/vmail.tar.gz vmail

3. Backing up dns data

Cd / var

Tar zcpf / backup/named.tar.gz named

4. Back up MySQL (the best combination with PHP) data (including URLForward databases)

Cd / var/lib

Tar zcpf / backup/MySQL (best combination with PHP). Tar.gz MySQL (best combination with PHP)

5. Back up the user data generated by the website

Cd / www/Prima (the most complete virtual host management system) / htdocs/apps/GenComSite

Tar zcpf / backup/GenComSite.tar.gz sitepage upload

6. Backup counter data

Cd / var/Counter

Tar zcpf / backup/CounterData.tar.gz data

7. Backup configuration

Cd / usr/Prima (the most complete virtual host management system)

Tar zcpf / backup/Prima (the most complete virtual host management system) _ etc.tar.gz etc

Cd / usr/Prima (the most complete virtual host management system) / postfix

Tar zcpf / backup/postfix_conf.tar.gz conf

Cd / usr/local/frontpage

Tar zcpf / backup/frontpage_cnf.tar.gz * .cnf

Cd / etc

Cp named.conf / backup/named.conf

Cd / www/Prima (the most complete virtual host management system) / htdocs/apps/phpMyAdmin

Cp config.inc.php / backup/config.inc.php

If you use resin (a free JSP running platform) to provide jsp (the first choice for SUN enterprise applications) services:

Cd / usr/local/resin (a free JSP operating platform) / conf

Cp host.conf / backup/resin (a free JSP running platform) _ host.conf

If you use tomcat (an easy to use JSP running platform) to provide jsp (the first choice for SUN enterprise applications) services:

Cd / var/tomcat (an easy to use JSP running platform) 4/conf

Cp server.xml (standardization is getting closer) / backup/server.xml (standardization is getting closer)

Master control configuration

(stand-alone version / professional version)

Cd / www/Prima (the most complete virtual host management system) / htdocs/common

Cp PUB.Config.inc / backup/PUB.Config.inc

(business version)

Cd / www/Prima (the most complete virtual host management system) / common

Cp DMC.Config.inc / backup/DMC.Config.inc

On the new server:

Please copy the backup from the original server to the new server

The following assumes that the copied backup is placed in / backup

0. Stop the service:

/ etc/init.d/httpd stop

/ etc/init.d/muddleftpd stop

/ etc/init.d/postfix stop

/ etc/init.d/courier-pop3d stop

/ etc/init.d/named stop

/ etc/init.d/MySQL (the best combination with PHP) d stop

/ etc/init.d/acald stop

1. Restore web data

Cd / www

Tar zxpf / backup/users.tar.gz

two。 Recover mail data

Cd / var

Tar zxpf / backup/vmail.tar.gz

3. Restore dns data

Cd / var

Tar zxpf / backup/named.tar.gz

4. Recover MySQL (the best combination with PHP) data

Cd / var/lib

Tar zxpf / backup/MySQL (the best combination with PHP). Tar.gz

5. Restore the website to generate user data

Cd / www/Prima (the most complete virtual host management system) / htdocs/apps/GenComSite

Tar zxpf / backup/GenComSite.tar.gz

6. Recover counter data

Cd / var/Counter

Tar zxpf / backup/CounterData.tar.gz

7. Restore configuration

Cd / usr/Prima (the most complete virtual host management system)

Tar zxpf / backup/Prima (the most complete virtual host management system) _ etc.tar.gz

Cd / usr/Prima (the most complete virtual host management system) / postfix

Tar zxpf / backup/postfix_conf.tar.gz

Cd / usr/local/frontpage

Tar zxpf / backup/frontpage_cnf.tar.gz

Cd / etc

Cp / backup/named.conf.

Cd / www/Prima (the most complete virtual host management system) / htdocs/apps/phpMyAdmin

Cp / backup/config.inc.php.

If you use resin (a free JSP running platform) to provide jsp (the first choice for SUN enterprise applications) services:

Cd / usr/local/resin (a free JSP operating platform) / conf

Cp / backup/resin (a free JSP running platform) _ host.conf. / host.conf

If you use tomcat (an easy to use JSP running platform) to provide jsp (the first choice for SUN enterprise applications) services:

Cd / var/tomcat (an easy to use JSP running platform) 4/conf

Cp / backup/server.xml (standardization is getting closer). / server.xml (standardization is getting closer and closer)

Master control configuration

(stand-alone version / professional version)

Cd / www/Prima (the most complete virtual host management system) / htdocs/common

Cp / backup/PUB.Config.inc.

(business version)

Cd / www/Prima (the most complete virtual host management system) / common

Cp / backup/DMC.Config.inc.

7. Synchronize system user information

7.1 Unified system user name is lowercase

Cat / usr/Prima (the most complete virtual host management system) / etc/usermap | awk'{printf ("% s% s\ n", $1) tolower ($2)}'> / usr/Prima (the most complete virtual host management system) / etc/usermap.new

Cp / usr/Prima (the most complete virtual host management system) / etc/usermap / usr/Prima (the most complete virtual host management system) / etc/usermap.old

Cp / usr/Prima (the most complete virtual host management system) / etc/usermap.new / usr/Prima (the most complete virtual host management system) / etc/usermap

Cat / usr/Prima (the most complete virtual host management system) / etc/httpd/virtual.conf | awk'{if (/ user_.* [Amurz] /) printf ("% s% s% s\ n"); else print $0;}'> / usr/Prima (the most complete virtual host management system) / etc/httpd/virtual.conf.new

Cp / usr/Prima (the most complete virtual host management system) / etc/httpd/virtual.conf / usr/Prima (the most complete virtual host management system) / etc/httpd/virtual.conf.old

Cp / usr/Prima (the most complete virtual host management system) / etc/httpd/virtual.conf.new / usr/Prima (the most complete virtual host management system) / etc/httpd/virtual.conf

7.2 recreate users and set permissions

Cd / root

Cat / usr/Prima (the most complete virtual host management system) / etc/usermap | awk'{printf ("/ usr/sbin/useradd-g ftpd-d / www/users/%s-s / no/shell-M% s\ nchown-R% s:ftpd / www/users/%s\ n", $1) > sync_sys_users.sh

Sh sync_sys_users.sh

8. Synchronize mail user information

(convert_vmail_id.sh attached)

Sh convert_vmail_id.sh

9. Start the service:

/ etc/init.d/httpd start

/ etc/init.d/muddleftpd start

/ etc/init.d/postfix start

/ etc/init.d/courier-pop3d start

/ etc/init.d/named start

/ etc/init.d/MySQL (the best combination with PHP) d start

/ etc/init.d/acald start

If used Java Support, and use resin (a free JSP operating platform)

/ etc/init.d/resin (a free JSP running platform) start

If used Java Support, and use tomcat (an easy to use JSP running platform)

/ etc/init.d/tomcat (an easy to use JSP running platform) 4 start

Done.

Appendix 1 convert_vmail_id.sh

#! / bin/sh

Userdb_dir= "/ usr/Prima (the most complete virtual host management system) / etc/mail/userdb"

Default_userdb= "$userdb_dir/default"

Makeuserdb_prog= "/ usr/Prima (the most complete virtual host management system) / maildrop/bin/makeuserdb"

Update_ugid_infile ()

{

If [- z "$1"] | | [- z "$2"] | | [- z "$3"]; then

Return 1

Fi

If [!-f $3]; then

Return 1

Fi

Sed-e "sUniid = [0-9] * / uid=$1/g" $3 > $3.tmp

If [$?! = 0]; then

Rm-f $3.tmp

Return 1

Fi

Cp $3.tmp $3

Rm-f $3.tmp

Sed-e "sbank GID = [0-9] * / gid=$1/g" $3 > $3.tmp

If [$?! = 0]; then

Rm-f $3.tmp

Return 1

Fi

Cp $3.tmp $3

Rm-f $3.tmp

Return 0

}

Vuid= `id-u vmail`

If [$?! = 0]; then

Echo "can not get vmail user id"

Exit 1

Fi

Vgid= `id-g vmail`

If [$?! = 0]; then

Echo "can not get vmail group id"

Exit 1

Fi

If [!-d $userdb_dir]; then

Echo "$userdb_dir does not exist or is not a dir"

Exit 1

Fi

For name in `ls $userdb_ dir`

Do

File= "$userdb_dir/$name"

If [- f $file]; then

Echo-n "Updating $name..."

If [$name! = "default"]; then

Update_ugid_infile $vuid $vgid $file

Else

Echo-e "vmail\ tuid=$vuid | gid=$vgid | home=/var/vmail | shell=/bin/bash | systempwrights packages!\ nroomvuid=\ tvmail\ nroot@$HOSTNAME\ tuid=$vuid | gid=$vgid | home=/var/vmail | mail=/var/vmail/root | systempwrights packages!" > $default_userdb

Fi

If [$? = 0]; then

Echo "success."

Else

Echo "fail."

Fi

Fi

Done

Echo

Echo "Rebuild db..."

$makeuserdb_prog

Echo "done."

Echo

Echo "bye."

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report