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 @@ ...@@ -3,8 +3,8 @@
# based on https://www.cyberciti.biz/faq/howto-move-migrate-user-accounts-old-to-new-server/ # based on https://www.cyberciti.biz/faq/howto-move-migrate-user-accounts-old-to-new-server/
# Author: Kai Lorenz # Author: Kai Lorenz
# Last update 07.03.2019 # Last update 07.03.2019
sudo su
sudo mkdir /move mkdir /move
cd /home/ || exit cd /home/ || exit
for f in */; do for f in */; do
# do some stuff here with "$f" # do some stuff here with "$f"
...@@ -12,10 +12,9 @@ for f in */; do ...@@ -12,10 +12,9 @@ for f in */; do
varTargerUser="$f" varTargerUser="$f"
if [[ $varTargerUser != *"webis"* ]];then if [[ $varTargerUser != *"webis"* ]];then
varArchiveName=$({ date +%Y; echo -; hostname; echo -; echo $varTargerUser; } | sed ':a;N;s/\n/ /;ba' | tr -d '[:space:]') varArchiveName=$({ date +%Y; echo -; hostname; echo -; echo $varTargerUser; } | sed ':a;N;s/\n/ /;ba' | tr -d '[:space:]')
sudo apt-get autoremove -y apt-get autoremove -y
echo "creating tar from home" 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 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
sudo mv -uv /move/* /mnt/nfs/webis20/code-in-archive/account-graveyard
fi fi
done done
...@@ -9,12 +9,11 @@ echo "Please enter the target username" ...@@ -9,12 +9,11 @@ echo "Please enter the target username"
read varTargerUser read varTargerUser
read -p "Please confirm, "$varTargerUser" is your target? Y/N " -n 1 -r read -p "Please confirm, "$varTargerUser" is your target? Y/N " -n 1 -r
echo # (optional) move to a new line echo # (optional) move to a new line
sudo su
if [[ $REPLY =~ ^[Yy]$ ]] if [[ $REPLY =~ ^[Yy]$ ]]
then then
varArchiveName=$({ date +%Y; echo -; hostname; echo -; echo $varTargerUser; } | sed ':a;N;s/\n/ /;ba' | tr -d '[:space:]') varArchiveName=$({ date +%Y; echo -; hostname; echo -; echo $varTargerUser; } | sed ':a;N;s/\n/ /;ba' | tr -d '[:space:]')
sudo mkdir /move mkdir /move
sudo 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
echo "creating tar from home" mv -uv /move/* /mnt/nfs/webis20/code-in-archive/account-graveyard
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
fi 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