Skip to content

Instantly share code, notes, and snippets.

@Spijkervet
Created October 4, 2019 14:55
Show Gist options
  • Save Spijkervet/c80a296f0c0d5eee49e42822053bc50d to your computer and use it in GitHub Desktop.
Save Spijkervet/c80a296f0c0d5eee49e42822053bc50d to your computer and use it in GitHub Desktop.
#!/bin/bash
CWDIR=$1
mkdir $CWDIR
echo 'Backing up to $CWDIR'
cd $CWDIR
export UGIDLIMIT=500
awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/passwd > $CWDIR/passwd.mig
awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/group > $CWDIR/group.mig
awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534) {print $1}' /etc/passwd | tee - |egrep -f - /etc/shadow > $CWDIR/shadow.mig
cp /etc/gshadow $CWDIR/gshadow.mig
cp -r /var/spool/mail $CWDIR/mail
rsync -a --info=progress2 /home $CWDIR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment