Algo assim?
#!/bin/bash
if [ $# -ne 2 ]; then # $# - is a number of arguments if its not equal (-ne) to 2 then we print message below and exit script
echo ${0}" [gzip|bzip2|xz] <user_name>"
echo -e "\tProgram will create backup of users home directory"
exit 0 # 0 is a return code of script
fi
case $1 in # $1 is first argument of script and case statement runs code depending of its content. for example: if $1 is equal to "gzip" then set method to "z"
"gzip" )
method="z" ;;
"bzip2" )
method="j" ;;
"xz" )
method="J" ;;
*)
# if $1 is none of above then run this
echo "Wrong method [gzip|bzip2|xz]"
exit 1 # and exit with return code 1 which means error
;;
esac
if [ ! -d /home/$2 ]; then # id not(!) existing directory(-d) /home/login ($2 is the second argument of script) then
echo "User not exists"
exit 1
fi
tar -${method} -cf ${2}_$(date +%F).tar.${1} /home/${2}
Poderia ser feito melhor e mais curto, mas esse código permite que você aprenda algo. Para mais informações sobre o tar, veja aqui: link