Problem
I want to migrate my SCO Unix users and printers from one SCO Unix server to another. The same steps are relevant regardless of operating system.
Solution
Follow the instructions below.Licenses:
========
Ensure the new server has the correct licensing added for the number
of users migrating. SCO Unix will detect duplicate licenses on the
same LAN so one approach if you plan to use the same licenses would
be to install with an Evaluation License, perform the migration then
turn off the old server and add the licensing to the new server once
the migration has been completed.Users:
=====
The recommended way to move users is to use the "ap" command.However, if the release of SCO Unix you are using doesn't have the "ap" command then the following procedure is suggested:
On a UnixWare 7 server:
----------------------
1. Add your users manually (from SCO UnixWare x) to the
/etc/passwd and /etc/shadow files with their passwords as defined
there or copy over the entire passwd and shadow files.It is recommended to take a copy of the files first, eg.
# mkdir -p /local/tmp
# cp /etc/passwd /local/tmp/passwd.orig
# cp /etc/shadow /local/tmp/shadow.orig2. Type:# cd /etc/security/ia
# mv * /local/tmp3. Run the auditcnv command (this will re-create a fresh audit file).
# auditcnv4. Run the creatiadb command (this will create a fresh index and master file).
# creatiadbYou should then be able to login as the user from the original server.
5. Create the user home directories and copy their content-- on the SCO UnixWare 2 server, type:
# find <users> -depth -print | cpio -ocvB | rsh <UW7 box>
"cd /home ; cpio -iBcvdum"This assumes that the correct /.rhosts and /etc/hosts.equiv are set up.
Please Note; if going between OSR5 to OSR6 then it recommended to drop the "B" flag.
For OpenServer5 and OpenServer6 substitute "rcmd" where "rsh" is used above, although OpenServer6 supports both "rcmd" and "rsh".
# find <users> -depth -print | cpio -ocvB |
rsh <remote box> "dd of=/dev/rmt/ctape0"or, if the tape supports a 32K blocking speed:
# find <users> -depth -print | cpio -ocvC32768 |
rsh <remote box> "dd of=/dev/rmt/ctape0 obs=32768"-> This would write the data to the other server's tape.
To read it, on the remote server run:
# cpio -itv{C32768} -I/dev/rmt/ctape0To restore it, back to your original server, from the remote server:
ie. the server with the tape attached.
# cpio -ivdumc {-C32768} -I/dev/rmt/ctape0 | cpio -ocvB | rsh <myserver> 'cd <users> ; cpio -ivdumcB'or from the original server:# rsh <remote box> dd if=/dev/rmt/ctape0 ibs=32768 | cpio -ivdumcC32768When using the "ap" command check to ensure that the /etc/group
permissions is set to 644 (-rw-r--r--) and /etc/passwd is set to
444 (-r--r--r--).'ap' provides a simple method of propagating user account profiles between UnixWare 7 or 2.1 systems.
Run the command:# ap -dgv > users.apThis will dump all the users so you can use your favorite editor to only include the user accounts and not the admin accounts when migrating to another server, such as "root", etc.
To import the users on the new server run:
# ap -r -v -f users.apThe "ap" command is also available for SCO UnixWare 2 from tls621:
https://ftp.scoexpert.com/TLSNOTE: The files offered in the Technical Library Supplements (TLS)
directory are for experimental or educational use only. They
are provided "AS IS" to knowledgeable users as a courtesy.They are NOT supported by SCO Support Services. All use of
this material is the sole responsibility of the user. See the
associated "README" files located in the TLS directory at SCO's
ftp site: https://ftp.scoexpert.com/TLSNOTE: You can run steps 2 and 3 above for Users if you have the situation
where a user is removed from /etc/passwd and /etc/shadow but is still
in the /etc/security/ia files and you get the message "User already
in use" when you try to run the "useradd" command.Printers:
========
Migrating from UW7 to UW7 server:
--------------------------------
1. Move /etc/lp/interfaces, /etc/lp/printers and /etc/lp/Systems to
a backup file:# cd /etc/lp
# find interfaces printers Systems -print | cpio -ovc -O printers.mig2. Copy over the printers.mig file to the other UW7 server under /etc/lp
3. Shutdown the printer scheduler:# /usr/sbin/lpshut4. Unpack the printer.mig file:# cd /etc/lp
# cpio -icvdum -I printers.mig5. Restart the LP scheduler:# /usr/lib/lpschedTo confirm that all went well. Type the following command:
# lpstat -tThis will return the list of the migrated printers, but they are disabled and not accepting print jobs.
6. Now we need to enable the printers and make them accept print jobs.
Write a small shell script to do job if the print list is big.
---- cut here ----
cd /etc/lp/printers
for i in *
do
enable $i
accept $i
done
---- cut here ----Once you run the script, all the printers will now be enabled and accepting print jobs. check with:
# lpstat -aMigrating from OSR6 to OSR6 server:
-----------------------------------
1. Move /etc/lp/interfaces, /etc/lp/printers and /etc/lp/classes to
a backup file:# cd /
# find /etc/printcap /etc/lp/interfaces /etc/lp/printers
/etc/clases -print | cpio -ovc -O /tmp/printers.mig2. Copy over the printer.mig file to the other OSR6 server under root level "/"
3. Shutdown the printer scheduler:# /usr/lib/lpshut4. Unpack the printer.mig file:# cd /
# cpio -icvdum -I printer.mig5. Restart the LP scheduler:# /usr/lib/lpschedTo confirm that all went well. Type the following command:
# lpstat -tThis will return the list of the migrated printers, but they are disabled and not accepting print jobs.
6. Now we need to enable the printers and make them accept print jobs. Write a small shell script to do job if the print list is big.
---- cut here ----
cd /etc/lp/printers
for i in *
do
enable $i
accept $i
done
---- cut here ----Once you run the script, all the printers will now be enabled and accepting print jobs.
Check with:# lpstat -aMigrating from OSR5 to OSR5/6 server:
-----------------------------------
1. Shutdown the printer scheduler on OSR5# /usr/lib/lpshut2. Move the whole /usr/spool/lp/admins/lp directory and /etc/printcap into a backup file:
# cd /
# find /usr/spool/lp/admins/lp /etc/printcap /usr/spool/lpd
-print | cpio -ocv -O /tmp/printer.mig3. Backup on the OSR6 box the original /usr/spool/lp/admins/lp directory structure:
# cd /usr/spool/lp/admins/lp
# find . -print | cpio -ocv -O /tmp/printer.orig4. Copy over the printer.mig file from OSR5 to OSR6 server under root level "/"
5. Shutdown the printer scheduler on OSR6:
# /usr/lib/lpshut6. Unpack the printer.mig file:# cd /
# cpio -icvdum -I printer.mig7. Restart the LP scheduler:# /usr/lib/lpschedTo confirm that all went well. Type the following command:
# lpstat -tThis will return the list of the migrated printers, but they are disabled and not accepting print jobs.
8. Now we need to enable the printers and make them accept print jobs.
Write a small shell script to do job if the print list is big.
---- cut here ----
cd /usr/spool/lp/admins/lp/printers
for i in *
do
enable $i
accept $i
done
---- cut here ----Once you run the script, all the printers will now be enabled and accepting print jobs.
Check with:# lpstat -aNOTE: For a cold standby server this could be incorporated into a simple
script as::
DATA=/local/backup export DATA
ap -dgv > $DATA/users.ap
cd /etc/lp
find interfaces printers classes Systems -print | cpio -ocv
-O$DATA/printers.cpiocp /etc/hosts $DATA/hosts.backup
cp /etc/resolv.conf $DATA/resolv.conf.backup
cp /usr/spool/cron/crontabs/root $DATA/crontab.rootThere are, of course, plenty of other files and configuration which
you may wish to migrate. For more information, see:http://www.sco.com/support/sysinfo.htmlApplication and Data:
====================
Before moving the customer's application solution to a new platform, we
need to consider:If the application is a statically built application that just uses the Operating System Runtime then there may be bug fixes or other changes to the Runtime that may affect the application.
If the application it has its own library set too then you need to take those libraries along with the application onto the new platform to see if it all works.
Either way we need to test before committing to the migration.
To copy an application or data we can use either restore from disk or tape, or use the network to copy, such as ftp, rcp, scp or rdist:
To sync up two directories, for example, the user's $HOME directories then ensure that there is .rhosts permissions for root between the two servers, ie user equivalence.
When you open an editor to create /.rhosts, it will probably have 644 permissions, so "chmod 600 /.rhosts" will be necessary.
Create a "distfile" in the form:HOSTS = ( root@lucy )FILES = ( /u3 )${FILES} -> ${HOSTS}
install -R ;Here, we are going to sync the files in /u3 from this server to "lucy" and run the command "rdist" in the form:
# rdist -iR -f distfileThis will add new files, update any changed files and remove any files that are on "lucy" but not your server.
NOTE: To copy data from one filesystem to another and retain all
permissions then use:# find . -print | cpio -pdumv /dataNOTE: It is noted that you use the -H crc option to back your data up on
OSR5 and try to use the default cpio on OSR6 to un-cpio your data
then you may experience a number of checksum verification errors.In this case, please use the OSR5 cpio shipped with OSR6 which can be found under:
/osr5/bin/cpioNOTE: To keep a regular backup of your essential files or backup prior to
an upgrade or migration, the following scripts are suggested as
guides to backing up and restoring your most critical files on the
root disk:---- cut here ---- backup_server.sh#!/bin/ksh
#
###############################################################################
#
# Script for backing up vital data from one system to another.
#
# Script to copy essential files to a data folder, maybe on external
# storage or could be backed up to another server or tape/cdrom
#
# Run as $0 2> errors.log
#
# When Migrating from one server to another or upgrading an existing
# server keep in mind that before you start:
#
# 1. Check the server's time and ensure the existing server is backed
# up.
# 2. Copy unix and resmgr in /stand to unix.sco and resgmr.sco
# 3. Check the kernel can be relinked with "/etc/conf/bin/idbuild -B"
# 4. Run this script to keep a record of essential services
# 5. Run "emergency_disk diskette1" and "dd" the images of those
# floppies onto the server to ensure their validity or boot from
# them to check them
# 6. Can the firmware be upgraded?
# 7. Can the HBA's be upgraded? If so, relink and reboot.
# 8. Upgrade the Maintenance Packs, relink and reboot.
# 9. Does additional services need upgrading, such as Java, Mozilla,
# other tools, or "nd" packages? If, relink and reboot.
# 10. Repeat the Emergency Floppy steps.
#
################################################################################ Setup Directory
DATA=/local/upgrade714 export DATA
if [ -d $DATA ]
then echo "directory already exists"
rm -rf $DATA
mkdir -p $DATA
else mkdir -p $DATA
fi# These files/directories are generic
echo "\nSaving User Account Information..."
cp -p /etc/passwd $DATA
cp -p /etc/group $DATA
cp -p /etc/shadow $DATA
ap -dg `cat /etc/passwd | cut -f1 -d: | grep -v root` >$DATA/user.apecho "\nCopying essential System Files..."
cp -p /etc/conf/sdevice.d/tcp $DATA
cp -p /etc/conf/sdevice.d/ticots $DATA
cp -p /etc/conf/sdevice.d/ticlts $DATA
cp -p /etc/conf/sdevice.d/ticotsor $DATA
cp -p /etc/hosts $DATA
cp -p /etc/vfstab $DATA
cp -p /usr/lib/drf/tapeconfig $DATA
cp -p /etc/inet/shells $DATA
cp -p /etc/inet/ntp.conf $DATA
cp -p /var/spool/cron/crontabs/root $DATA
cp -p /etc/cron.d/cron.allow $DATA
cp -p /.profile $DATA
cp -p /.rhosts $DATA
cp -p /etc/default/cdrecord $DATA
cp -p /usr/lib/samba/lib/smb.conf $DATA
cp -p /usr/lib/samba/private/smbpasswd $DATA
cp -p /etc/conf/cf.d/stune $DATA
cp -p /etc/netmgt/snmpd.trap $DATA
cp -p /etc/netmgt/snmpd.comm $DATA# Web Services
cp -p /usr/lib/apache/conf/httpd.conf $DATA
cd /usr/lib/apache
find ./htdocs -print | cpio -ocvB -O $DATA/apache-htdocs.cpio
find ./auth -print | cpio -ocvB -O $DATA/apache-auth.cpio
cd /# User's Data
echo "\nCopying existing /home folders..."
cd /
find home -print | cpio -ocvB -O $DATA/home.cpioecho "Outputting sdiconfig -l to sdiconfig..."
sdiconfig -l > $DATA/sdiconfigecho "\nOutputting ifconfig -a to ifconfig..."
ifconfig -a > $DATA/ifconfigecho "\nListing the content of /etc/rc2.d directory..."
ls -l /etc/rc2.d > $DATA/rc2.d.txt
ls -l /etc/rc0.d > $DATA/rc0.d.txtecho "\nCopying any backup and verify scripts..."
#cp -p /etc/rc2.d/S10backup $DATA
#cp -p /etc/rc2.d/S99verify $DATAecho "\nCopying any Database startup scripts..."
#cp -p /etc/init.d/oracle $DATA/oracle_startstopecho "\nCopying any Application startup scripts..."
#cp -p /etc/rc2.d/S99rc.formsmaster $DATA
#cp -p /etc/rc0.d/K03rc.formsmaster $DATAecho "\nCopying Any Applications ..."
#find /backups -print | cpio -ocvB -O $DATA/backups.cpioecho "\nCopying any essential Application Configuration Files..."
cp -p /etc/skel/.profile $DATA/stduser.profileecho "\nCopying any essential Utilities Files..."
#cd /
#find ./tools -print | cpio -ocvB -O $DATA/tools.cpioecho "\nSaving the Printer configuration..."
cd /etc/lp
find classes interfaces printers Systems -print | cpio -ovcB -O $DATA/printers.cpio
#cp -p /etc/lp/model/forms4_master $DATAecho "\n\n\tDone - all in $DATA"----- end here -----Restore Script:----- cut here ----- restore_server.sh#!/bin/sh
#
########################################################################
#
# Script for updating the system password, samba password, user home
# directories and printers since upgrade build was performed in the test suite
#
########################################################################
#
#
DATA=/local/upgrade714 export DATA
if [ ! -d $DATA ]
then
echo "\n\tWARNING: $DATA directory does not exist!!!"
echo "\tCan't continue this script. Aborting!!!!\n"
exit
fi# updating and restoring the user password DataBase
cp -p /etc/passwd /etc/passwd.orig
cp -p /etc/shadow /etc/shadow.orig
cp -p /etc/group /etc/group.origcp -p $DATA/passwd /etc
cp -p $DATA/group /etc
cp -p $DATA/shadow /etcap -ro -f $DATA/user.ap >/dev/null 2>&1mv /etc/security/ia/audit $DATA
mv /etc/security/ia/o* $DATA
mv /etc/security/ia/index $DATA
mv /etc/security/ia/master $DATA/usr/sbin/auditcnv
/usr/sbin/creatiadb
/etc/security/ia/setpriv -x# Restoring the Home users directories
cd /
cpio -icvdum -I $DATA/home.cpio# updating the Samba passowrd files
cp -p $DATA/smb.conf /usr/lib/samba/lib
cp -p $DATA/smbpasswd /usr/lib/samba/private# Migrating the printers
sleep 2
/usr/lib/lpshut
cd /etc/lp
cpio -icvdum -I $DATA/printers.cpio
/usr/lib/lpsched
cd /
sleep 2
for i in `lpstat -a | awk '{print $1}' | egrep -v new`
do
accept $i >/dev/null 2>&1
enable $i >/dev/null 2>&1
donecp $DATA/root /var/spool/cron/crontabs/root
chmod 600 /var/spool/cron/crontabs/root
chown root:sys /var/spool/cron/crontabs/root
#
echo "\n\tServer Restored...\n"---- end cut -----TROUBLESHOOTING:
---------------Migrating OSR5 disk to OSR6 Notes:-Install wd supplement before migration! -Administer the disk at the source system FIRST before migration -OSR6 Divvy now works on OSR5 (wd) and OSR6 disks
Limitations: -There is no conversion for UW VTOC disks to dual format OSR6 -OSR6 does not support extended VTOC slices
Always back your data before migration!Migrating from OSR5 to OSR6 Notes:- DO NOT BLINDLY import OSR5 tunables from OSR6:
E.g. buffer cache has different use on OSR6 Identify the performance problem you are trying to solve first! [ GOLDEN RULE ] Take measurements /etc/conf/bin/idtune SCOadmin has a wrapper for idtune
NOTES: Looking for a script to accomplish this then try the following:The actual commands are commented out for the purposes of user testing before using.
-----:
#!/bin/sh
#
# Copyright (c) 2010 The Santa Cruz Operation, Inc. All Rights Reserved.
#
# migration.sh script
# Usage: migration.sh [ ? ]
#
#set -x
#
DATE=`date +%Y%m%d%H%M%S`
LOWEST_UID=199
MIGRATION_HOME="/local/migration"
OS=`uname`
case ${OS} in
SCO_SV) PRINTERS="/usr/spool/lp/admins/lp"
AP_BIN=/tcb/bin/ap
;;
UnixWare) PRINTERS="/etc/lp"
AP_BIN=/usr/sbin/ap
;;
*) echo "Unknown OS"
exit 1
esac[ -f /etc/default/migration ] && {
. /etc/default/migration
}# Definitions
USAGE="Usage: %s [ ]"
LABEL="UX:`basename $0`"
PATH="/bin:/usr/bin:/etc:/usr/gnu/bin"; export PATHprepare() {
if [ ! -d ${MIGRATION_HOME} ]; then
mkdir -p ${MIGRATION_HOME}
fi
}users_out() {
if [ -x ${AP_BIN} ]; then
cat /etc/passwd | while read i
do
NUID=`echo $i | cut -d: -f3`
VUID=`expr ${NUID}`
if [ ${VUID} -gt ${LOWEST_UID} ]; then
NAME=`echo $i | cut -d: -f1`
${AP_BIN} -dvg ${NAME} >> ${MIGRATION_HOME}/users.${DATE}.ap
cp ${MIGRATION_HOME}/users.${DATE}.ap ${MIGRATION_HOME}/users.ap
fi
done
else
echo "No ${AP_BIN} found!"
exit 1
fi
}backup_users() {
mkdir -p ${MIGRATION_HOME}/backup
if [ -x ${AP_BIN} ]; then
echo "Backing up to ${MIGRATION_HOME}/backup/user.${DATE}.ap"
${AP_BIN} -dg >> ${MIGRATION_HOME}/backup/user.${DATE}.ap
else
echo "No ${AP_BIN} found!"
exit 1
fi
}add_users() {
if [ -x ${AP_BIN} ]; then
if [ ! ${MIGRATION_HOME}/backup ]; then
echo "${MIGRATION_HOME} is missing!"
exit 1
else
echo " "
echo "Listing Available files (users.*ap) ..."
echo " "
lc ${MIGRATION_HOME}/users.*ap | pg
echo " "
echo "Enter the Users File to restore from (default: users.ap):"
read FILE
if [ "${FILE}" = "" ]; then
FILE=users.ap
fi
if [ ! -f ${MIGRATION_HOME}/${FILE} ]; then
echo "${MIGRATION_HOME}/${FILE} does not exist!"
exit 1
else
# ${AP_BIN} -r -v -f ${MIGRATION_HOME}/${FILE}
echo "${AP_BIN} -r -v -f ${MIGRATION_HOME}/${FILE}"
fi
fi else
echo "No ${AP_BIN} found!"
exit 1
fi
}printers_out() {
if [ -d ${PRINTERS} ]; then
find ${PRINTERS} /etc/printcap /usr/spool/lpd -print | cpio -ovc -O${MIGRATION_HOME}/printers.${DATE}.cpio
cp ${MIGRATION_HOME}/printers.${DATE}.cpio ${MIGRATION_HOME}/printers.cpio
fi
}backup_printers() {
if [ ! ${MIGRATION_HOME}/backup ]; then
echo "${MIGRATION_HOME} is missing!"
exit 1
else
if [ -d ${PRINTERS} ]; then
echo "Backing up printers to ${MIGRATION_HOME}/backup/printers.{$DATE}.cpio"
find ${PRINTERS} /etc/printcap /usr/spool/lpd -print | cpio -ovc -O${MIGRATION_HOME}/backup/printers.${DATE}.cpio
fi
fi
}
add_printers() {
if [ ! ${MIGRATION_HOME}/backup ]; then
echo "${MIGRATION_HOME} is missing!"
exit 1
else
echo " "
echo "Listing Available files (printers.*cpio) ..."
echo " "
lc ${MIGRATION_HOME}/printers.*cpio | pg
echo " "
echo "Enter the printers File to restore from (default: printers.cpio):"
read FILE
if [ "${FILE}" = "" ]; then
FILE=printers.cpio
fi
if [ ! -f ${MIGRATION_HOME}/${FILE} ]; then
echo "${MIGRATION_HOME}/${FILE} does not exist!"
exit 1
else
# /usr/lib/lpshut
# cpio -ivdumc -I${MIGRATION_HOME}/${FILE}
# /usr/lib/lpsched
echo "/usr/lib/lpshut"
echo "cpio -ivdumc -I${MIGRATION_HOME}/${FILE}"
echo "/usr/lib/lpsched"
cd ${PRINTERS}/printers
for i in *
do
# /usr/bin/enable $i
echo "/usr/bin/enable $i"
done
fi
fi
}copy_files() {
if [ ! -f ${MIGRATION_HOME}/file_list ]; then
echo "Create the list of files to copy in ${MIGRATION_HOME}/file_list"
echo "or use the following as an example:"
echo " "
echo "/home"
echo "/app"
echo "/data"
echo "/.profile"
echo "/etc/default"
echo "/etc/conf/cf.d/stune"
echo "/etc/smb.conf"
echo "/etc/sendmail/sendmail.cf"
echo "/usr/spool/cron/crontabs"
else
while read i
do
if [ ! "${i}" = "" ]; then
case $i in
/etc) echo "All of /etc not allowed!"
;;
/) echo "All of / not allowed"
;;
*) # rcp ${SERVER}:$i $i
echo "rcp ${SERVER}:$i $i"
;;
esac
fi
done < ${MIGRATION_HOME}/file_list
fi
}run_wizard() {
prepare
tput clear
echo "Welcome to the Migration Wizard:"
echo "--------------------------------"
echo " "
echo "First of all I need to know is the existing production server"
echo "we are migrating from or the new server we are migrating to?"
echo " "
echo "This method supports OSR507/600 <-> OSR507/600 (including V)"
echo "and to and from UnixWare (ap is supported on all platforms)"
echo " "
echo "In other words, are we on the [OLD] or [NEW] server? "
read ANSWER
case ${ANSWER} in
OLD) echo " "
echo "First we are going to migrate the users ..."
users_out
echo "Then the printers ... "
printers_out
echo " "
echo "Next we need to copy over :"
echo " "
echo "1 - The user's HOME directories"
echo "2 - The Application"
echo "3 - The Data"
echo "4 - Any Additional Applications this server runs"
echo "5 - Any Subsequent System Admin Utilities"
echo "6 - Any subsequent configuration files such as :"
echo " "
echo " crontabs"
echo " Mail Configuration (MMDF or Sendmail)"
echo " Samba Configuration"
echo " /etc/default/"
echo " /etc/conf/cf.d/stune"
echo " "
echo "To do this we need to establish a trust and copy over the"
echo "files as detailed in TA 125883;
echo " "
;;
NEW) echo " "
echo "First we are going to backup the users and printes to ${MIGRATION_HOME}/backup"
backup_users
backup_printers
echo " "
echo "Next, we load the users, hit RETURN to continue:"
read CONT
add_users
echo " "
echo "Next, we load the printers, hit RETURN to continue:"
read CONT
add_printers
echo " "
echo "Next, we copy over the HOME directories, application, data and configuration files, hit RETURN to continue:"
read CONT
echo "Enter the name of the old server to copy from or just enter RETURN to quit:"
read SERVER
if [ "${SERVER}" = "" ]; then
exit 0
fi
copy_files
;;
*) echo " "
echo "Invalid Answer!"
exit 1
;;
esac
echo " "
echo "Farewell!"
}#############################################################################
# main()
############################################################################## check the usage of the script
if [ $# -lt 1 ]; then
run_wizard
exit 0
fi# function to perform is in $1
function="$1"# execute the routine for the requested function case $function in
output)
echo $function ;;
input)
echo $function ;;
query)
echo $function ;;
*)
echo "$USAGE\n" `basename $0`
exit 1 ;;
esac# done
exit 0
----- See also
TA125883, "UW7:How can I copy files from one UnixWare7 server to another?"
http://www.sco.com/support/docs/openserver/600/migration/index.html