Here is a one-line example, given two parameters. $1 is the archive name prefix and $2 is the directory to archive.
tar -cvzf ${1}-$(date +%Y%m%d-%H%M).tar.gz $2
Note, if $2 contains path information (such as absolute path), that path will be stored in the tar. So it is usually used with the working dir as the parent of $2.
Here is a one-line example, given two parameters. $1 is the archive name prefix and $2 is the directory to archive.
Note, if $2 contains path information (such as absolute path), that path will be stored in the tar. So it is usually used with the working dir as the parent of $2.