singleuser.sh 1016 Bytes
Newer Older
Kai Lorenz's avatar
Kai Lorenz committed
1
#!/usr/bin/env bash
2
# Utility Tool to archive a single user account on a standard webis machine
Kai Lorenz's avatar
Kai Lorenz committed
3
# based on https://www.cyberciti.biz/faq/howto-move-migrate-user-accounts-old-to-new-server/ 
4
# Author: Kai Lorenz
Kai Lorenz's avatar
Kai Lorenz committed
5 6 7 8 9 10 11
# Last update 24.02.2019

ls /home/
echo "Please enter the target username"
read varTargerUser
read -p "Please confirm, "$varTargerUser" is your target? Y/N " -n 1 -r
echo    # (optional) move to a new line
12
sudo su 
Kai Lorenz's avatar
Kai Lorenz committed
13 14 15
if [[ $REPLY =~ ^[Yy]$ ]]
then
	varArchiveName=$({ date +%Y; echo -; hostname; echo -; echo $varTargerUser; } | sed ':a;N;s/\n/ /;ba' | tr -d '[:space:]')
16 17 18
	mkdir /move
	tar --exclude='/home/$varTargerUser/.local/share/Trash/' --exclude='/home/$varTargerUser/.cache/mozilla' --exclude='/home/$varTargerUser/.wine' --exclude='/home/$varTargerUser/.cache/google-chrome' --exclude='/home/$varTargerUser/.cache/pip' --exclude='/home/$varTargerUser/.cache/thumbnails' -zcvpf /move/$varArchiveName.tar.gz /home/$varTargerUser
	mv -uv /move/* /mnt/nfs/webis20/code-in-archive/account-graveyard
Kai Lorenz's avatar
Kai Lorenz committed
19
fi