Dann ist Dein Server irgendwie nicht richtig installiert.
Ahh, ok. Hatte ich ganz vergessen Logge Dich in ISPConfig ein, gehe zu tools > resync, aktiviere alle Optionen und klicke auf Resync.
#!/bin/bash
#Voraussetzung: Neuer Server hat ssh-Zugriff mit Key auf alten Server, migrate läuft auf neuem Server
OLD_IP="x.x.x.x" # or domain-name
RSYNCBIN="/usr/bin/rsync"
SQLBIN="/usr/bin/mysql"
SQLDUMP="/usr/bin/mysqldump"
USER="root" # root-user for the mysql-db
PASS="password" # root password for the mysql-db
DBISPC="dbispconfig"
OLD_SQLBIN="/usr/bin/mysql"
OLD_SQLDUMP="/usr/bin/mysqldump"
OLD_USER="root" # root-user for the old mysql-db
OLD_PASS="pass" # root password for the old mysql-db
OLD_DBISPC="dbispconfig"
#Optional: Section Copy Files can be done one day before so that copy while real migration takes less time
#Optional: set all DNS-TTL to 5 minutes 1 day before migration? If you do this save the ttls somewhere else !!!!
#$OLD_SQLBIN -u$OLD_USER -p$OLD_PASS $OLD_DBISPC -e "UPDATE dns_rr SET ttl=300;"
#And now resync dns-zones on old server -> wait one day, and then migrate
#after migration:
#$SQLBIN -u$USER -p$PASS $DBISPC -e "UPDATE dns_rr SET ttl=86400;"
#And now resync dns-zones on new server
#Fetch passwd and group from old server
`scp $OLD_IP:/etc/passwd /tmp/oldpasswd`
`scp $OLD_IP:/etc/shadow /tmp/oldshadow`
`scp $OLD_IP:/etc/group /tmp/oldgroup`
`scp $OLD_IP:/etc/gshadow /tmp/oldgshadow`
#Remove if not wanted!
#Delete all web* and client* entries on new system, to avoid double names
`/etc/passwd < grep -v '^web[0-9]\{1,\}' /etc/passwd`
`/etc/shadow < grep -v '^web[0-9]\{1,\}' /etc/shadow`
`/etc/group < grep -v '^client[0-9]\{1,\}' /etc/group`
`/etc/gshadow < grep -v '^client[0-9]\{1,\}' /etc/gshadow`
#Delete /var/vmail and /var/www on new server to avoid double names
`rm -Rf /var/vmail/*`
`rm -Rf /var/www/*`
# WHAT ABOUT SSH-USERS????
#copy from old files to new files
`/etc/passwd << grep '^web[0-9]\{1,\}' /tmp/oldpasswd`
`/etc/shadow << grep '^web[0-9]\{1,\}' /tmp/oldshadow`
`/etc/group << grep '^client[0-9]\{1,\}' /tmp/oldgroup`
`/etc/gshadow << grep '^client[0-9]\{1,\}' /tmp/oldgshadow`
# Now stop services on old server, that could be used by clients
`ssh $OLD_IP "service stop apache2"`
`ssh $OLD_IP "service stop postfix"`
`ssh $OLD_IP "service stop dovecot"`
# Copy mail and web-files
`$RSYNCBIN -az -H --delete $OLD_IP:/var/vmail/* /var/vmail`
`$RSYNCBIN -az -H --delete $OLD_IP:/var/www/* /var/www`
# Copy ispconfig database
`ssh $OLD_IP "$OLD_SQLDUMP -u$OLD_USER -p$OLD_PASS -h localhost $OLD_DBISPC > /tmp/dbispconfig.sql"`
`scp $OLD_IP:/tmp/dbispconfig.sql /tmp/dbispconfig.sql`
`$SQLBIN -u$USER -p$PASS < /tmp/dbispconfig.sql`
# Copy client databases -> savedatabases.sh must exist on old server
#Content for savedatabases.sh
#----------------------------------
#OLD_SQLBIN="/usr/bin/mysql"
#OLD_SQLDUMP="/usr/bin/mysqldump"
#OLD_USER="root" # root-user for the mysql-db
#OLD_PASS="pass" # root password for the mysql-db
#OLD_DBISPC="dbispconfig"
#$OLD_SQLBIN -u$OLD_USER -p$OLD_PASS $OLD_DBISPC -e "select database_name from web_database order by database_id asc;" | grep [a-zA-Z0-9] | grep -v 'database_name' |
#while read DBNAME
#do
#$OLD_SQLBIN -u$OLD_USER -p$OLD_PASS $OLD_DBISPC -e "SELECT CONCAT(c.username,'_',w.database_name) AS FILENAME FROM client c, web_database w WHERE w.sys_groupid = c.client_id+1 AND w.database_name = '$DBNAME';" | grep [a-zA-Z0-9] | grep -v 'FILENAME' |
#while read FILENAME
#do
#$OLD_SQLDUMP -u$OLD_USER -p$OLD_PASS -h localhost $DBNAME > /tmp/ispc_client_db_$FILENAME'.sql'
#done
#done
#----------------------------------
`ssh $OLD_IP "~/savedatabases.sh"`
`scp $OLD_IP:/tmp/ispc_client_db_*.sql /tmp/`
`for f in /tmp/ispc_client_db_*.sql; do "$SQLBIN -u$USER -p$PASS < $f"; done;`
Würde dieser Komplettumzug durch Backups wie beschrieben auch von einem OpenSuse 13.x auf ein Debian-System funktionieren?Umzug eines ISPConfig 3 Servers bzw. erstellen einer Serverkopie:
Der Punkt ist aber: ich weiß genau, dass das passt - das alte System war debian, das neue auch, beide Male nur mit ISPConfig erstellt und in den ssh-usern war kein anderer User außer der 5002 und den web* drin. und die 5002 war auch auf dem neuen System drin -> also kein Problem - das bitte vorher prüfen.sed -i 's/^sshusers:.*$/'`grep sshusers: \/tmp\/oldgroup`'/' /etc/group
sed -i 's/^sshusers:.*$/'`grep sshusers: \/tmp\/oldgshadow`'/' /etc/gshadow
#!/bin/bash
# What to do before:
# Install ispconfig on new server in exactly the same version as on
# the old server (including plugins and so on) activate same plugins
# (and modules) by linking available-xxx to enabled-xxx like on the
# old server
# set variables in this script in section SETTINGS
# remove not wanted parts - e.g. deleting data on new server (if
# you want to keep already created users and data on new server)
# Optional migration infos
# 1. Section "COPY MAIL AND WEB FILES" can be done additionally
# already before, so that copy while real migration takes less time
# 2. set all DNS-TTL to 5 minutes 1 day before migration? If you do this
# save the ttls somewhere else !!!!
# $OLD_SQLBIN -u$OLD_USER -p$OLD_PASS $OLD_DBISPC -e "UPDATE dns_rr SET ttl=300;"
# And now resync dns-zones on old server -> wait one day, and then migrate
#
# after migration:
# $SQLBIN -u$USER -p$PASS $DBISPC -e "UPDATE dns_rr SET ttl=86400;"
# And now resync dns-zones on new server
#------------------------------------------------------------
# SETTINGS
#------------------------------------------------------------
NEWIP="x.x.x.x"
RSYNCBIN="/usr/bin/rsync"
SQLBIN="/usr/bin/mysql"
SQLDUMP="/usr/bin/mysqldump"
USER="root" # root-user for the mysql-db
PASS="password" # root password for the mysql-db
DBISPC="dbispconfig"
BACKUP_DIR="/var/backup/" # with / at the end !!!!
DKIM_DIR="/var/lib/amavis/dkim/" # with / at the end !!!!
OLD_IP="x.x.x.x" # or domain-name
OLD_SQLBIN="/usr/bin/mysql"
OLD_SQLDUMP="/usr/bin/mysqldump"
OLD_USER="root" # root-user for the old mysql-db
OLD_PASS="password" # root password for the old mysql-db
OLD_DBISPC="dbispconfig"
#------------------------------------------------------------
# STOP ACCESS TO OLD SERVER
#------------------------------------------------------------
# First stop services on old server, that could be used by clients
# mysql must be kept alive for migration - to be sure that noone accesses remote-db
# you can add "bind-address=127.0.0.1" to my.cnf so only localhost can access dbs
#ssh $OLD_IP "sed -i 's/^#bind-address/bind-address/' /etc/mysql/my.cnf"
#ssh $OLD_IP "/etc/init.d/mysql restart"
#ssh $OLD_IP "/etc/init.d/apache2 stop"
#ssh $OLD_IP "/etc/init.d/postfix stop"
#ssh $OLD_IP "/etc/init.d/dovecot stop"
#------------------------------------------------------------
# COPY SYSTEM USERS AND GROUPS
#------------------------------------------------------------
#Fetch passwd and group from old server
scp $OLD_IP:/etc/passwd /tmp/oldpasswd
scp $OLD_IP:/etc/shadow /tmp/oldshadow
scp $OLD_IP:/etc/group /tmp/oldgroup
scp $OLD_IP:/etc/gshadow /tmp/oldgshadow
#save current users and groups
cp /etc/passwd /etc/passwd.old
cp /etc/shadow /etc/shadow.old
cp /etc/group /etc/group.old
cp /etc/gshadow /etc/gshadow.old
#Remove if not wanted!
#Delete all web* and client* entries on new system, to avoid double names
sed -i '/^web[0-9]\{1,\}/d' /etc/passwd
sed -i '/^web[0-9]\{1,\}/d' /etc/shadow
sed -i '/^client[0-9]\{1,\}/d' /etc/group
sed -i '/^client[0-9]\{1,\}/d' /etc/gshadow
#Delete /var/vmail and /var/www on new server to avoid double names
#rm -Rf /var/vmail/*
#rm -Rf /var/www/*
#copy from old files to new files
grep '^web[0-9]\{1,\}' /tmp/oldpasswd >> /etc/passwd
grep '^web[0-9]\{1,\}' /tmp/oldshadow >> /etc/shadow
grep '^client[0-9]\{1,\}' /tmp/oldgroup >> /etc/group
grep '^client[0-9]\{1,\}' /tmp/oldgshadow >> /etc/gshadow
#attention: sshusers may contain additional users
sed -i 's/^sshusers:.*$/'`grep sshusers: \/tmp\/oldgroup`'/' /etc/group
sed -i 's/^sshusers:.*$/'`grep sshusers: \/tmp\/oldgshadow`'/' /etc/gshadow
#------------------------------------------------------------
# COPY MAIL, WEB AND BACKUP FILES
#------------------------------------------------------------
$RSYNCBIN -avz -H --delete $OLD_IP:/var/vmail/* /var/vmail
$RSYNCBIN -avz -H --delete $OLD_IP:/var/www/* /var/www
$RSYNCBIN -avz -H --delete $OLD_IP:$BACKUP_DIR'*' $BACKUP_DIR
$RSYNCBIN -avz -H --delete $OLD_IP:$DKIM_DIR'*' $DKIM_DIR
#------------------------------------------------------------
# COPY ISPCONFIG DATABASE
#------------------------------------------------------------
ssh $OLD_IP "$OLD_SQLDUMP -u$OLD_USER -p$OLD_PASS -h localhost $OLD_DBISPC > /tmp/dbispconfig.sql"
scp $OLD_IP:/tmp/dbispconfig.sql /tmp/dbispconfig.sql
$SQLBIN -u$USER -p$PASS $DBISPC < /tmp/dbispconfig.sql
$SQLBIN -u$USER -p$PASS $DBISPC -e "UPDATE dns_rr SET ttl=86400;"
$SQLBIN -u$USER -p$PASS $DBISPC -e "UPDATE dns_rr SET data='"$NEWIP"' WHERE data='"$OLD_IP"';"
$SQLBIN -u$USER -p$PASS $DBISPC -e "UPDATE dns_soa SET ttl=86400, minimum=86400;"
#------------------------------------------------------------
# COPY CLIENT DATABASES
#------------------------------------------------------------
# savedatabases.sh must exist on old server
#Content for savedatabases.sh
#----------------------------------
#!/bin/bash
#
#OLD_SQLBIN="/usr/bin/mysql"
#OLD_SQLDUMP="/usr/bin/mysqldump"
#OLD_USER="root" # root-user for the mysql-db
#OLD_PASS="rootpass" # root password for the mysql-db
#OLD_DBISPC="dbispconfig"
#
#cat /dev/null > /tmp/ispc_client_databases.txt
#$OLD_SQLBIN -u$OLD_USER -p$OLD_PASS $OLD_DBISPC -e "select database_name from web_database order by database_id asc;" | grep [a-zA-Z0-9] | grep -v 'database_name' |
#while read DBNAME
#do
#echo $DBNAME >> /tmp/ispc_client_databases.txt
#echo -n "Database $DBNAME: ... "
#$OLD_SQLDUMP -u$OLD_USER -p$OLD_PASS -h localhost $DBNAME > /tmp/ispc_client_db_$DBNAME'.sql'
#echo "done"
#done
#
#cat /dev/null > /tmp/ispc_client_database_users.txt
#$OLD_SQLBIN -u$OLD_USER -p$OLD_PASS $OLD_DBISPC -e "select database_user from web_database_user order by database_user_id asc;" | grep [a-zA-Z0-9] | grep -v 'database_user' |
#while read DBUSER
#do
#echo $DBUSER >> /tmp/ispc_client_database_users.txt
#echo "Databaseuser $DBUSER"
#done
#
##Now fetch Rows of mysql.db and mysql.user tables
#DBNAMES=while read dbname; do echo -n "'$dbname', "; done < /tmp/ispc_client_databases.txt; echo "'dummyformigration'"
#$OLD_SQLDUMP -u$OLD_USER -p$OLD_PASS -t -h localhost mysql db --where="Db IN ($DBNAMES)" > /tmp/ispc_mysql.dbs.sql
#DBUSERS=while read dbuser; do echo -n "'$dbuser', "; done < /tmp/ispc_client_database_users.txt; echo "'dummyformigration'"
#$OLD_SQLDUMP -u$OLD_USER -p$OLD_PASS -t -h localhost mysql user --where="User IN ($DBUSERS)" > /tmp/ispc_mysql.users.sql
#----------------------------------
ssh $OLD_IP "~/savedatabases.sh"
scp $OLD_IP:/tmp/ispc_client_databases.txt /tmp/
scp $OLD_IP:/tmp/ispc_client_database_users.txt /tmp/
scp $OLD_IP:/tmp/ispc_client_db_*.sql /tmp/
scp $OLD_IP:/tmp/ispc_mysql.dbs.sql /tmp/
scp $OLD_IP:/tmp/ispc_mysql.users.sql /tmp/
# Now import all client databases
while read dbname
do
$SQLBIN -u$USER -p$PASS -e "DROP DATABASE IF EXISTS $dbname; CREATE DATABASE $dbname;"
$SQLBIN -u$USER -p$PASS $dbname < /tmp/ispc_client_db_$dbname'.sql'
done < /tmp/ispc_client_databases.txt
#------------------------------------------------------------
# COPY DATABSE ACCESS RIGHTS
#------------------------------------------------------------
# import rows of mysql.dbs and mysql.users
$SQLBIN -u$USER -p$PASS mysql < /tmp/ispc_mysql.users.sql
$SQLBIN -u$USER -p$PASS mysql < /tmp/ispc_mysql.dbs.sql
#------------------------------------------------------------
# RESTART SERVICES ON NEW SERVER
#------------------------------------------------------------
/etc/init.d/mysql restart
/etc/init.d/apache2 restart
/etc/init.d/postfix restart
/etc/init.d/dovecot restart
#------------------------------------------------------------
# FINISH
#------------------------------------------------------------
echo "ATTENTION: YOU MUST RESYNC ALL DATA IN ISPConfig now to create e.g. VHOST-Files"
mysqldump -u root -p --events --all-databases --ignore-table=mysql.innodb_index_stats --ignore-table=mysql.innodb_table_stats > ~/db_backup/mysql-dump_$(date +"%Y-%m-%d_%s").sql
for i in $(cat ~/db_backup/databases-list); do mysqldump -u root -p --databases $i --ignore-table=mysql.innodb_index_stats --ignore-table=mysql.innodb_table_stats > ~/db_backup/mysql-dump-$i-$(date +"%Y-%m-%d_%s").sql; done
mysql mysql -u root -p -e 'show tables like "db%"' | grep -v Tables_in | xargs mysqldump mysql -u root -p > ~/db_backup/mysql-dump-mysql-db-$(date +"%Y-%m-%d_%s").sql
mysql mysql -u root -p -e 'show tables like "user%"' | grep -v Tables_in | xargs mysqldump mysql -u root -p > ~/db_backup/mysql-dump-mysql-user-$(date +"%Y-%m-%d_%s").sql
rsync -avAXEWSlHhP -e ssh -p 22 / --delete --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/cdrom/*,/lost+found} root@[BACKUPSERVER]:/home/rsync/ | tee rsync_$(date +"%Y-%m-%d_%s").log
Wir verwenden essentielle Cookies, damit diese Website funktioniert, und optionale Cookies, um den Komfort bei der Nutzung zu verbessern.
Siehe weitere Informationen und konfiguriere deine Einstellungen