...also it doesn't make sense to have a user enter the date as backup scripts tend to run as much unattended as possible (more than anything it's a discipline thing IMHO). And using
DDMMYYYY looks nice but when you have to sort things "%Y%m%d_${HOSTNAME}" or "${HOSTNAME}_%Y%m%d_${LOGNAME}" or "%Y%m%d_${HOSTNAME}_${DIRECTORIES}" makes much more sense.
If you want to make it easier for a user you could use a simple menu like this:
Code:
select SELECTDATE in today custom ; do
case $SELECTDATE in
today) USEDATE=$(/bin/date +'%Y%m%d');;
*) echo -en "Set the date: "; read USEDATE;;
esac; break;
done;
# Now "$USEDATE" is the string you can use to populate the tarball name with.
Such simple menus can also be used to query for use of other things like if the tarball name should contain the hostname, name of the current user, which directory or directories to back up, etc, etc.
Code:
function howto() { echo "Bash scripting guides:
http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
http://www.tldp.org/LDP/Bash-Beginners-Guide/html/index.html
http://www.gnu.org/software/bash/manual/html_node/index.html
http://www.grymoire.com/Unix/Sh.html
http://www.tldp.org/LDP/abs/html/
http://mywiki.wooledge.org/BashFAQ
http://mywiki.wooledge.org/BashPitfalls"; }