title: How to create and append a log file while creating archive using tar
body: <p>My intention is to create a bash script which will archive the folder every day and create a archive status in a text file. </p>
  
  <p>If I have a folder called /files/daily_updates, I would do something like below:</p>
  
  <pre><code>#!/bin/bash
  #Create archive of daily update
  
  NOW=$(date +%Y%m%d%H)
  LOG_FILE=/var/log/updates_$NOW.log
  
  tar -czvf /archive/daily_backup_$DATE.tar.gz /updates/daily_updates 1&gt; $LOG_FILE 2&gt;&amp;1
  tar -ztvf /archive/daily_backup_$DATE.tar.gz 1&gt; $LOG_FILE 2&gt;&amp;1
  </code></pre>
  
  <p>My log file updates_#.log should look like normal log file:</p>
  
  <pre><code>10-20-2014 04:45:29 INFO Creating archive of folder..
  10-20-2014 04:46:01 INFO Archive created of file: filename, size = 102 MB
  10-20-2014 04:48:21 ERROR 
  </code></pre>
  
  <p>Few questions:</p>
  
  <ol>
  <li><p>The second tar command overwrites the logs created by the first one, how do I avoid this?</p></li>
  <li><p>I am only able to write standard STDERR and STDOUT of tar so far. Can I put the output in the log file format mentioned above?</p></li>
  <li><p>Is there any alternative, may be a python script or even java?</p></li>
  </ol>