Bash backup script failing using tar and --newer option
Hello, I'm trying to write a simple bash backup script. It works....well, sort of and that's why I'm here.
Basic scenario. I want to perform an incremental backup where I check the last time a backup was completed. To do this, I have a reference text file ($LastBackup) that has one line, a date. So here are the lines in question.
tar --newer=$(cat $LastBackup) -cjf BackupFile.tar.gz2 $BackupDirectory
echo $(date +%m/%d/%Y) > $LastBackup
The idea here is to run the tar command and then update the the time in the $LastBackup file. Now, if I run it this way, all I get in my tar file is the directory structure. The strange thing is, if I remove the second line (echo ....), then the script works fine meaning that the newer files get tar'ed. It's as if the echo line runs before the tar line which doesn't make any sense to me.
Thanks for any help.
-Sal
|