Last active
December 24, 2015 04:49
-
-
Save l-margiela/6746933 to your computer and use it in GitHub Desktop.
Migrating users from server to server. Scirpt to run on old server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
MIGRATIONBACKUPDIR=migration_backup | |
mkdir $MIGRATIONBACKUPDIR | |
cp /etc/passwd /etc/shadow /etc/group /etc/gshadow $MIGRATIONBACKUP | |
cd $1 | |
cat passwd.mig >> /etc/passwd | |
cat group.mig >> /etc/group | |
cat shadow.mig >> /etc/shadow | |
tar -zxvf home.tar.gz -C / |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
UGIDLIMIT=1000 | |
DEST=sobieski.3lab.re | |
MIGRATIONDIR=migration | |
mkdir $MIGRATIONDIR | |
awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/passwd > $MIGRATIONDIR/passwd.mig | |
awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/group > $MIGRATIONDIR/group.mig | |
awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534) {print $1}' /etc/passwd | tee - |egrep -f - /etc/shadow > $MIGRATIONDIR/shadow.mig | |
tar -zcvpf --preserve-ownership --numeric-owner $MIGRATIONDIR/home.tar.gz /home | |
rsync -Ravz -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" --progress $MIGRATIONDIR $DEST:~/ | |
ssh root@$DEST 'bash -s' < migration_dest.sh $MIGRATIONDIR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment