I'm looking to configure this backup script to take the current day's date and make the directory in a mmddyyyy format, as this will be automated. However, if the directory with that current day already exists (if I needed to do more than one backup on a given day), I want to add -1 or -2, so that it would appear 07072011-3 (if it were the 4th backup being made that day).
is there a simple way to add onto the end of the directory name, +1 for each time it's been written?
Set date/folder name
today="$ (date +%m%d%Y)"
Check if dir exists
if [ ! -d /home/user/backup/$today ]
echo Directory already exists ;