- Jun 10, 2004
- 31
- 0
- 0
Yep yep, it's me again!
In my kick-ass script *roll eyes*, I want to do a tarball backup of a user's home directory and then delete the user's account and the user's home directory, leaving a tarball backup of the deleted directory in /root/users_deleted.
Here's the part of the script:
With this version of the script, it does create the backup file (even though the date doesn't show correctly, it prints date +"%Hh%M_%d-%m-%Y" as the filename (after $2_ of course).
The problem with the script is that it always give me the error that it couldn't create a backup of the user's file. I guess it isn't working mainly because of the bad filename of the tarball..?
Thanks, Frank
In my kick-ass script *roll eyes*, I want to do a tarball backup of a user's home directory and then delete the user's account and the user's home directory, leaving a tarball backup of the deleted directory in /root/users_deleted.
Here's the part of the script:
echo -n "Removing $2..."
if cat /etc/passwd | grep "^$2:" > /dev/null; then
tar -czf /root/users_deleted/$2_'date +"%Hh%M_%d-%m-%Y"'.tgz /home/$2
if [ $? == 0 ]; then
$userdel $2
if cat /etc/passwd | grep "^$2:" > /dev/null; then
echo " Done."
exit 0
else
echo " ERROR: Could not delete account."
exit 1
fi
else
echo " ERROR: Could not create a backup of $2's files."
exit 1
fi
else
echo " ERROR: $2 does not exist."
exit 1
fi
With this version of the script, it does create the backup file (even though the date doesn't show correctly, it prints date +"%Hh%M_%d-%m-%Y" as the filename (after $2_ of course).
The problem with the script is that it always give me the error that it couldn't create a backup of the user's file. I guess it isn't working mainly because of the bad filename of the tarball..?
Thanks, Frank