Koozali.org: home of the SME Server

SME 6 => SME 7 migration.

silasp

SME 6 => SME 7 migration.
« on: March 14, 2006, 04:33:32 AM »
Hello.
Here is my (somewhat) successful SME 6 => SME 7 migration guide. Mind you, it's still a work in progress.

[1] Backup with rsync
Code: [Select]

# Make sure you check
# /usr/lib/perl5/site_perl/esmith/Backup.pm
# for the correct backup file list for your SME version
# it begins with "sub restore_list" (near line 70)

# Replace this IP with your remote host IP
RMH=192.168.1.1

cd /
# All these are directories - note trailing slashes
rsync -vPa -e ssh $RMH:/home/e-smith/ /home/e-smith/
rsync -vPa -e ssh $RMH:/etc/e-smith/templates-custom/ /etc/e-smith/templates-custom/
rsync -vPa -e ssh $RMH:/etc/e-smith/templates-user-custom/ /etc/e-smith/templates-user-custom/

# All these are files - note no trailing slashes
rsync -vPa -e ssh $RMH:/etc/group /etc/group
rsync -vPa -e ssh $RMH:/etc/gshadow /etc/gshadow
rsync -vPa -e ssh $RMH:/etc/passwd /etc/passwd
rsync -vPa -e ssh $RMH:/etc/shadow /etc/shadow
rsync -vPa -e ssh $RMH:/etc/samba/smbpasswd /etc/samba/smbpasswd
rsync -vPa -e ssh $RMH:/etc/samba/secrets.tdb /etc/samba/secrets.tdb
rsync -vPa -e ssh $RMH:/etc/smbpasswd /etc/smbpasswd
rsync -vPa -e ssh $RMH:/etc/sudoers /etc/sudoers


Remember to also backup any mysql databases you have running on the server.

[2] New install SME 7 from CD

[3] On the SME 7 server, backup the following files:
cp /etc/group /etc/group.bu
cp /etc/gshadow /etc/gshadow.bu
cp /etc/passwd /etc/passwd.bu
cp /etc/shadow /etc/shadow.bu

[4] Restore the files you backed up in [1] by running the same script on the new server and changing the IP to the server you backed the files up to.

signal-event post-upgrade
signal event reboot

Most things should work after this.

[5] Fix broken bits by copying any users and passwords missing from the group, gshadow, passwd and shadow files from the backups you made in step [3] - I'm not sure if cat group.bu >> group (etc) will do this - or whether it is better to use text editors and cut / paste.

[6] Log on as administrator to the "local machine" of all your windoze machines and rejoin the domain (you might have to temporarily join workgroup "nothing" to do this)

[7] Set up printers, etc

[8] Install contribs (eg Phpmyadmin, SME7Admin)

This worked for me. I recently did a YUM update and have run into some minor problems, but other than that, everything was pain-free.

Cheers,
Silas

Offline gordonr

  • *
  • 646
  • +0/-0
    • http://www.smeserver.com.au/
Re: SME 6 => SME 7 migration.
« Reply #1 on: March 15, 2006, 07:37:22 AM »
Quote from: "silasp"
Hello.
Here is my (somewhat) successful SME 6 => SME 7 migration guide. Mind you, it's still a work in progress.


The correct procedure is:

Code: [Select]
signal-event pre-restore
  ...copy the files and directories listed in the restore_list...
signal-event post-upgrade
signal-event reboot


There should be no manual editing of /etc files required. You needed to because you didn't run pre-restore prior to doing what amounts to a restore.
............

silasp

Where have you been all my life.
« Reply #2 on: March 16, 2006, 10:43:14 AM »
Hello, thank you so much for posting this. Wow, that's great!
I've cross-posted a similar guide elsewhere, and will edit it accordingly, thankyou for helping out.

So that pre-restore thing takes care of all the problems associated with similar entries in the "new" and "old" user and group files? (Eg there's a clamd user entry in both the sme 6 and sme 7 passwd files, but they have different UID, PID and default shell.) That's really cool!

Cheers,
Silas.

Offline timlitw

  • *
  • 35
  • +0/-0
Re: SME 6 => SME 7 migration.
« Reply #3 on: March 17, 2006, 08:51:07 PM »
this is what I came up with based on your script - I'm testing it now
you will have to have the old sme root password and enter it for each new rsync instance that runs.
Code: [Select]
#!/bin/sh

#####################################################################################
# This script modified from contribs.org forums - can be run from new server only.
# it will run pre-restore to prepare the new sme server to accept the files and
# setting from the old server.
# then will use rsync to get needed files from the olde server to the temp directory
# then it will use rsync to merge them with the current files
# finally it will run post-upgrade and reboot to get the server back to the correct
# operating state.
#
# After I trust it more - the first rsync will be altered to modify the original file
# on the first rsync - then it won't need the temp folder.
#
#####################################################################################

signal-event pre-restore

# Replace this IP with your old sme server ip address
RMH=192.168.2.18
# Local Temp Directory
LTD=/root/tmp/


# make temporary storage place
cd $LTD
mkdir -p etc/samba
mkdir -p home/e-smith


# backup original users and groups to userbackup.tar.gz
tar -czvf /root/userbackup.tar.gz /etc/group /etc/gshadow /etc/passwd /etc/shadow

# prepare to merge current users and users from backup
rsync -vPa /etc/group $LTD/etc/group
rsync -vPa /etc/gshadow $LTD/etc/gshadow
rsync -vPa /etc/passwd $LTD/etc/passwd
rsync -vPa /etc/shadow $LTD/etc/shadow
rsync -vPa /etc/samba/smbpasswd $LTD/etc/samba/smbpasswd
rsync -vPa /etc/samba/secrets.tdb $LTD/etc/samba/secrets.tdb
rsync -vPa /etc/smbpasswd $LTD/etc/smbpasswd
rsync -vPa /etc/sudoers $LTD/etc/sudoers



# Make sure you check
# /usr/lib/perl5/site_perl/esmith/Backup.pm
# for the correct backup file list for your SME version
# it begins with "sub restore_list" (near line 70)


cd $LTD
# All these are directories - note trailing slashes
rsync -vPa -e ssh $RMH:/home/e-smith/ $LTD/home/e-smith/
rsync -vPa -e ssh $RMH:/etc/e-smith/templates-custom/ $LTD/etc/e-smith/templates-custom/
rsync -vPa -e ssh $RMH:/etc/e-smith/templates-user-custom/ $LTD/etc/e-smith/templates-user-custom/


# All these are files - note no trailing slashes
rsync -vPa -e ssh $RMH:/etc/group $LTD/etc/group
rsync -vPa -e ssh $RMH:/etc/gshadow $LTD/etc/gshadow
rsync -vPa -e ssh $RMH:/etc/passwd $LTD/etc/passwd
rsync -vPa -e ssh $RMH:/etc/shadow $LTD/etc/shadow
rsync -vPa -e ssh $RMH:/etc/samba/smbpasswd $LTD/etc/samba/smbpasswd
rsync -vPa -e ssh $RMH:/etc/samba/secrets.tdb $LTD/etc/samba/secrets.tdb
rsync -vPa -e ssh $RMH:/etc/smbpasswd $LTD/etc/smbpasswd
rsync -vPa -e ssh $RMH:/etc/sudoers $LTD/etc/sudoers


cd /
# All these are directories - note trailing slashes
rsync -vPa $LTD/home/e-smith/ /home/e-smith/
rsync -vPa $LTD/etc/e-smith/templates-custom/ /etc/e-smith/templates-custom/
rsync -vPa $LTD/etc/e-smith/templates-user-custom/ /etc/e-smith/templates-user-custom/


# All these are files - note no trailing slashes
rsync -vPa $LTD/etc/group /etc/group
rsync -vPa $LTD/etc/gshadow /etc/gshadow
rsync -vPa $LTD/etc/passwd /etc/passwd
rsync -vPa $LTD/etc/shadow /etc/shadow
rsync -vPa $LTD/etc/samba/smbpasswd /etc/samba/smbpasswd
rsync -vPa $LTD/etc/samba/secrets.tdb /etc/samba/secrets.tdb
rsync -vPa $LTD/etc/smbpasswd /etc/smbpasswd
rsync -vPa $LTD/etc/sudoers /etc/sudoers


signal-event post-upgrade
signal-event reboot

Offline brianr

  • *
  • 988
  • +2/-0
SME 6 => SME 7 migration.
« Reply #4 on: March 18, 2006, 11:13:55 AM »
How do you get rsync NOT to ask for a password for each call?
Brian j Read
(retired, for a second time, still got 2 installations though)
The instrument I am playing is my favourite Melodeon.
.........

Offline timlitw

  • *
  • 35
  • +0/-0
SME 6 => SME 7 migration.
« Reply #5 on: March 18, 2006, 03:15:27 PM »
If you want to do that here are instructions

http://new.linuxjournal.com/article/8600

ro scroll down to simplefying ssh on this page
http://nerdvittles.com/index.php?p=123

silasp

Avoid typing passwords:
« Reply #6 on: March 20, 2006, 04:48:31 AM »
Avoid typing passwords into the rsync script:
[Sorry for the cross-posting]

Log in as root to the local (new) server, enter
cd /root/.ssh
ssh-keygen -t rsa
(choose a randomish name eg "keyname" and press enter twice when prompted for a passphrase)

chmod 600 keyname*
scp keyname.pub [ip of remote server]:/root/.ssh/
(enter root password)

- Now connect to the Old server (replace 192.168.1.1 with actual ip)
ssh 192.168.1.1
(log on as root)
cd /root/.ssh

if [ ! -f authorized_keys ]; then touch authorized_keys ; chmod 600 authorized_keys ; fi
(above "if" command should all be on one line)
cat keyname.pub >> authorized_keys
rm -f keyname.pub
exit

Now you should be able to execute the script above without password prompts.

Cheers,
Silas.

Offline brianr

  • *
  • 988
  • +2/-0
SME 6 => SME 7 migration.
« Reply #7 on: March 20, 2006, 12:14:30 PM »
Ok, this is the code I used, some corrections to avoid double "/" on some file paths, and also to initially create the /root/tmp directory.

I have used it sucessfully (with the keygen from above), and the new server seems to have all the data, emails, passwords etc that it needs.  Am running in test mode for a couple of days before committing to the new one.

This script looks as though it could also form the basis for an overnight sync of one server to another.

Code: [Select]
#!/bin/sh

#####################################################################################
# This script modified from contribs.org forums - can be run from new server only.
# it will run pre-restore to prepare the new sme server to accept the files and
# setting from the old server.
# then will use rsync to get needed files from the olde server to the temp directory
# then it will use rsync to merge them with the current files
# finally it will run post-upgrade and reboot to get the server back to the correct
# operating state.
#
# After I trust it more - the first rsync will be altered to modify the original file
# on the first rsync - then it won't need the temp folder.
#
#####################################################################################

signal-event pre-restore

# Replace this IP with your old sme server ip address
RMH=192.168.100.2
# Local Temp Directory
mkdir -p /root/tmp
LTD=/root/tmp


# make temporary storage place
cd $LTD
mkdir -p etc/samba
mkdir -p home/e-smith


# backup original users and groups to userbackup.tar.gz
tar -czvf /root/userbackup.tar.gz /etc/group /etc/gshadow /etc/passwd /etc/shadow

# prepare to merge current users and users from backup
rsync -vPa /etc/group $LTD/etc/group
rsync -vPa /etc/gshadow $LTD/etc/gshadow
rsync -vPa /etc/passwd $LTD/etc/passwd
rsync -vPa /etc/shadow $LTD/etc/shadow
rsync -vPa /etc/samba/smbpasswd $LTD/etc/samba/smbpasswd
rsync -vPa /etc/samba/secrets.tdb $LTD/etc/samba/secrets.tdb
rsync -vPa /etc/smbpasswd $LTD/etc/smbpasswd
rsync -vPa /etc/sudoers $LTD/etc/sudoers



# Make sure you check
# /usr/lib/perl5/site_perl/esmith/Backup.pm
# for the correct backup file list for your SME version
# it begins with "sub restore_list" (near line 70)


cd $LTD
# All these are directories - note trailing slashes
rsync -vPa -e ssh $RMH:/home/e-smith/ $LTD/home/e-smith/
rsync -vPa -e ssh $RMH:/etc/e-smith/templates-custom/ $LTD/etc/e-smith/templates-custom/
rsync -vPa -e ssh $RMH:/etc/e-smith/templates-user-custom/ $LTD/etc/e-smith/templates-user-custom/


# All these are files - note no trailing slashes
rsync -vPa -e ssh $RMH:/etc/group $LTD/etc/group
rsync -vPa -e ssh $RMH:/etc/gshadow $LTD/etc/gshadow
rsync -vPa -e ssh $RMH:/etc/passwd $LTD/etc/passwd
rsync -vPa -e ssh $RMH:/etc/shadow $LTD/etc/shadow
rsync -vPa -e ssh $RMH:/etc/samba/smbpasswd $LTD/etc/samba/smbpasswd
rsync -vPa -e ssh $RMH:/etc/samba/secrets.tdb $LTD/etc/samba/secrets.tdb
rsync -vPa -e ssh $RMH:/etc/smbpasswd $LTD/etc/smbpasswd
rsync -vPa -e ssh $RMH:/etc/sudoers $LTD/etc/sudoers


cd /
# All these are directories - note trailing slashes
rsync -vPa $LTD/home/e-smith/ /home/e-smith/
rsync -vPa $LTD/etc/e-smith/templates-custom/ /etc/e-smith/templates-custom/
rsync -vPa $LTD/etc/e-smith/templates-user-custom/ /etc/e-smith/templates-user-custom/


# All these are files - note no trailing slashes
rsync -vPa $LTD/etc/group /etc/group
rsync -vPa $LTD/etc/gshadow /etc/gshadow
rsync -vPa $LTD/etc/passwd /etc/passwd
rsync -vPa $LTD/etc/shadow /etc/shadow
rsync -vPa $LTD/etc/samba/smbpasswd /etc/samba/smbpasswd
rsync -vPa $LTD/etc/samba/secrets.tdb /etc/samba/secrets.tdb
rsync -vPa $LTD/etc/smbpasswd /etc/smbpasswd
rsync -vPa $LTD/etc/sudoers /etc/sudoers


signal-event post-upgrade
signal-event reboot
Brian j Read
(retired, for a second time, still got 2 installations though)
The instrument I am playing is my favourite Melodeon.
.........

vdeg

SME 6 => SME 7 migration.
« Reply #8 on: April 24, 2006, 08:20:04 PM »
Hi
I used this script to migrate to SME 7 from  SME 6.0.1 and everything worked except for webmail this is what I get when I go to https://myserver/webmail/
A fatal error has occurred
DB Error: connect failed Details have been logged for the administrator.
here is the error from message log.
Apr 24 14:05:38 newstupig HORDE[17134]: [horde] DB Error: connect failed:  [nativecode=Access denied for user 'horde'@'localhost' (using password: YES)] ** Array [on line 1329 of "/home/httpd/html/horde/lib/Horde/DataTree/sql.php"]
any idea how to fix this?
thanks

Offline timlitw

  • *
  • 35
  • +0/-0
SME 6 => SME 7 migration.
« Reply #9 on: April 24, 2006, 09:27:56 PM »
yeh, run  the post-upgrade event again and the reboot. It apparently didn't finish and mysql isn't running

Offline netspirit

  • 14
  • +0/-0
    • http://www.om-conseil.com
SME 6 => SME 7 migration.
« Reply #10 on: September 18, 2006, 04:35:12 PM »
Hi all!

I'am facing problem using this script to migrate. After runing it and redo a signal-event post-upgrade
signal event reboot
several times, I still do not have the MySQL db. So I copied them by hand (stopping MySQL during copy) but still getting dabase connection errors on all web site and Horde.
Is there anybody who has a sure migration howto?
Thanks in advance.
...
Nous ne savons pas le vrai si nous ne savons la cause - PLATON
www.om-conseil.com

Offline timlitw

  • *
  • 35
  • +0/-0
SME 6 => SME 7 migration.
« Reply #11 on: September 18, 2006, 04:48:37 PM »
Open another console and tail /var/log/messages
while runing the signal-event post-upgrade
see if there is anything erroring during the post-upgrade
that might help us narrow it down.

Offline ddougan

  • *
  • 151
  • +0/-0
    • http://www.DouganConsulting.com
SME 6 => SME 7 migration.
« Reply #12 on: September 23, 2006, 07:28:15 PM »
Might the problem be that the procedure doesn't run the pre-backup routine on the old server, and that therefore the MySQL database(s) haven't been dumped and then brought over?
Des Dougan

Offline raem

  • *
  • 3,972
  • +4/-0
SME 6 => SME 7 migration.
« Reply #13 on: September 23, 2006, 08:47:47 PM »
netspirit

> I still do not have the MySQL db. So I copied them by hand (stopping MySQL during copy) but still getting database connection errors on all web site and Horde.

Did you copy the mysql db too ?
If not you need to add all your users back in there.
Also set correct permissions
cd /var/lib
chown -R mysql:mysql mysql
...

Offline raem

  • *
  • 3,972
  • +4/-0
SME 6 => SME 7 migration.
« Reply #14 on: September 23, 2006, 08:57:49 PM »
netspirit

> the MySQL database(s) haven't been dumped

See
/etc/e-smith/events/actions/mysql-dump-tables

which will create a dump file called
/home/e-smith/db/mysql/mysql.dump
...