Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Having trouble with making a backup script for automatically updating the var folder to another server nightly

BDATE=`date +%F`
 rsync --exclude=foldera/folderb -bavz --backup-dir=backup-$(BDATE)

This doesn't seem to be working when I run it, have I done something wrong?


share|improve this question

migrated from Jun 14 '11 at 13:22

This question came from our site for pro webmasters.

up vote 0 down vote accepted

At a first glance, your problem seems to be the --backup-dir flag. The $(BDATE) won't expand to the date. Just try this from a terminal:


echo $BDATE --> 14-06-2011

echo foo-$(BDATE) --> DATE: command not found foo-

if you use this foo-$BDATE it will work: echo foo-$BDATE --> foo-14-06-2011

Also, can you please post the output if it still doesn't work?

share|improve this answer

$( ) is command substitution, like the backticks: `` If you are trying isolate a variable you use curly braces, e.g., ${foo}_bar will reference the var foo. In this case, $BDATE doesn't need any such isolation. FYI $(( )) is arithmetic evaluation.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.