Posted by : Unknown Minggu, 15 Juli 2012



P. Bagaimana memigrasi atau memindahkan akun-akun user dari server linux lama ke server linux baru, termasuk email dan lainnya? untuk fresh install server
A. Anda dapat menindahkan aku-akun user dari server linux lama ke yang baru dengan command standar seperti tar, awk, scp dan lainnya. Ini juga berguna jika anda menggunakan versi linux lama seperti Redhat 9 atau Debian 2.x.

File atau direktori berikut yang ada pada user management di linux versi umum:
/etc/passwd - berisi informasi penting dari akun-akun user
/etc/shadow - berisi tentang informasi dari password-password yang telah di enkripsi

/etc/group - berisi tentang informasi rup dari masing-masing user
/etc/gshadow - group shadow file (berisi enkripsi password dari grup)
/var/spool/mail - Tempat penyimpanan email pada umumnya
/home - data dari user-user.
anda harus backup semua file dan direktori di atas..

Perintah pada system Linux yang lama

Pertama buat sebuah tar ball  (Sistem Linux yang lama). buat sebuah direktori:
# mkdir /root/move/
Setup UID filter limit:
# export UGIDLIMIT=500
Sekarang copy /etc/passwd accounts ke /root/move/passwd.mig menggunalkan awk  untuk memfilter sistem account  (Hanya mengkopi akun user)
# awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/passwd > /root/move/passwd.mig
Copy /etc/group file:
# awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/group > /root/move/group.mig
Copy /etc/shadow file:
# awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534) {print $1}' /etc/passwd | tee - |egrep -f - /etc/shadow > /root/move/shadow.mig
Copy /etc/gshadow (Optional):
# cp /etc/gshadow /root/move/gshadow.mig
Buat backup untuk /home dan /var/spool/mail direktori:
# tar -zcvpf /root/move/home.tar.gz /home
# tar -zcvpf /root/move/mail.tar.gz /var/spool/mail
Dimana,
  • Users that are added to the Linux system always start with UID and GID values of as specified by Linux distribution or set by admin. Limits according to different Linux distro:
    • RHEL/CentOS/Fedora Core : Default is 500 and upper limit is 65534 (/etc/libuser.conf).
    • Debian and Ubuntu Linux : Default is 1000 and upper limit is 29999 (/etc/adduser.conf).
  • You should never ever create any new system user accounts on the newly installed Cent OS Linux. So above awk command filter out UID according to Linux distro.
  • export UGIDLIMIT=500 - setup UID start limit for normal user account. Set this value as per your Linux distro.
  • awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/passwd > /root/move/passwd.mig - You need to pass UGIDLIMIT variable to awk using -v option (it assigns value of shell variable UGIDLIMIT to awk program variable LIMIT). Option -F: sets the field separator to : . Finally awk read each line from /etc/passwd, filter out system accounts and generates new file /root/move/passwd.mig. Same logic is applies to rest of awk command.
  • tar -zcvpf /root/move/home.tar.gz /home - Make a backup of users /home dir
  • tar -zcvpf /root/move/mail.tar.gz /var/spool/mail - Make a backup of users mail dir
Gunakan scp atau usb pen atau tape untuk mengcopy  /root/move ke sistem Linux yang baru.
# scp -r /root/move/* user@new.linuxserver.com:/path/to/location

Perintah yang dijalankan di Sistem Linux yang baru

Pertama, buat backup untuk akun-akun di sistem yang baru:
# mkdir /root/newsusers.bak
# cp /etc/passwd /etc/shadow /etc/group /etc/gshadow /root/newsusers.bak

Sekarang monkopi passwd dan file-file sistem lainnya ke /etc/
# cd /path/to/location
# cat passwd.mig >> /etc/passwd
# cat group.mig >> /etc/group
# cat shadow.mig >> /etc/shadow
# /bin/cp gshadow.mig /etc/gshadow
Catatan : gunakan >> (tambah) dan bukan > (buat baru) shell redirection.
Sekarang copy dan extract home.tar.gz ke  /home server yang baru
# cd /
# tar -zxvf /path/to/location/home.tar.gz
Sekarang copy dan extract mail.tar.gz (Mails) ke /var/spool/mail server yang baru
# cd /
# tar -zxvf /path/to/location/mail.tar.gz
Sekarang Restart sistem, ketika kembali, akun-akun user anda akan kembali seperti sebelum anda install ulang server tersebut:
# reboot
Teknik di atas dapat digunakan dari UNIX ke UNIX ATAU UNIX ke Linux. Pada prinsipnya untuk semua distro linux command akan sama tinggal dilakukan sedikit penyesuaian sesuai dengan kebutuhan dan platform.

Description: Migrasi akun user dari Server Linux lama ke server Linux Baru
Rating: 4.5
Reviewer: Unknown
ItemReviewed: Migrasi akun user dari Server Linux lama ke server Linux Baru

Leave a Reply

Monggo Tinggalkan Jejak Kaks :)

Subscribe to Posts | Subscribe to Comments

Welcome to My Blog

Popular Post

Labels

Arsip Blog

Followers

- Copyright © 2013 shad0w-share | Designed by Johanes Djogan -