Q:
How to copy Airwave shell users (root privilege) from old server to new server?
A:
Below are the list of files where root users related information is stored in Airwave. We need to take the backup of all this files from old to new Airwave server.
1) /etc/shadow –> it contains users password in encrypted format
2) /etc/group –> It contains list of user's groups information
3) /etc/passwd -> It contain users accounts information
4) /var/spool/mail –> users emails stored
5) /etc/gshadow –> It contain group password in encrypted format
6) /home –> Users data stored in this location.
First create a tar files of old server users.
Create a directory
# mkdir /tmp/backup/
Setup UID filter limit:
# export UGIDLIMIT=500
Now copy /etc/passwd accounts to /tmp/backup/passwd.mig using awk to filter out system account (i.e. only copy user accounts)
# awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/passwd > /tmp/backup/passwd.mig
Copy /etc/group file:
# awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/group > /tmp/backup/group.mig
Copy /etc/shadow file:
# awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534) {print $1}' /etc/passwd | tee - |egrep -f - /etc/shadow > /tmp/backup/shadow.mig
Copy /etc/gshadow (rarely used):
# cp /etc/gshadow /tmp/backup/gshadow.mig
Make a backup of /home and /var/spool/mail directories
# tar -zcvpf /tmp/backup/home.tar.gz /home
# tar -zcvpf /tmp/backup/mail.tar.gz /var/spool/mail
Users that are added in Airwave always start with UID and GID values of as specified by Linux distribution or set by admin.
Limits according to different Linux flavors:
In RHEL/CentOS/Fedora core, default is 500 and upper limit is 65534 (/etc/libuser.conf).
In debian and ubuntu Linux, default is 1000 and upper limit is 29999 (/etc/adduser.conf).
Since Airwave built on Centos 6.6, default UID is 500 and upper limit is 65534
Use scp or usb pen or tape to copy /tmp/backup/ to a new Linux system.
# scp -r /tmp/backup/* user@new.linuxserver.com:/tmp/
Commands to type on new Airwave server
First, make a backup of current users and passwords:
# mkdir /tmp/users.bak
# cp /etc/passwd /etc/group /etc/gshadow /etc/shadow /tmp/newsusers.bak
Now restore passwd and other files in /etc/
# cd /tmp/
# cat shadow.mig >> /etc/shadow
# /bin/cp gshadow.mig /etc/gshadow
# cat passwd.mig >> /etc/passwd
# cat group.mig >> /etc/group
Now copy and extract home.tar.gz to new server /home
# cd /
# tar -zxvf /tmp/home.tar.gz
Now copy and extract mail.tar.gz (Mails) to new server /var/spool/mail
# cd /
# tar -zxvf /tmp/mail.tar.gz
once restore is done, reboot the server
# reboot