Commit a9d4f672 authored by Kai Lorenz's avatar Kai Lorenz

removed bug creating command and changed to root user

parent 41cad866
......@@ -3,8 +3,8 @@
# based on https://www.cyberciti.biz/faq/howto-move-migrate-user-accounts-old-to-new-server/
# Author: Kai Lorenz
# Last update 07.03.2019
sudo mkdir /move
sudo su
mkdir /move
cd /home/ || exit
for f in */; do
# do some stuff here with "$f"
......@@ -12,10 +12,9 @@ for f in */; do
varTargerUser="$f"
if [[ $varTargerUser != *"webis"* ]];then
varArchiveName=$({ date +%Y; echo -; hostname; echo -; echo $varTargerUser; } | sed ':a;N;s/\n/ /;ba' | tr -d '[:space:]')
sudo apt-get autoremove -y
echo "creating tar from home"
sudo 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
sudo mv -uv /move/* /mnt/nfs/webis20/code-in-archive/account-graveyard
apt-get autoremove -y
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
fi
done
......@@ -9,12 +9,11 @@ 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
sudo su
if [[ $REPLY =~ ^[Yy]$ ]]
then
varArchiveName=$({ date +%Y; echo -; hostname; echo -; echo $varTargerUser; } | sed ':a;N;s/\n/ /;ba' | tr -d '[:space:]')
sudo mkdir /move
sudo apt-get autoremove -y
echo "creating tar from home"
sudo 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
sudo mv -uv /move/* /mnt/nfs/webis20/code-in-archive/account-graveyard
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
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment