title: Bash script to archive files and then copy new ones
body: <p>Need some help with this as my shell scripting skills are somewhat less than l337 :(</p>
  
  <p>I need to gzip several files and then copy newer ones over the top from another location. I need to be able to call this script in the following manner from other scripts.</p>
  
  <pre><code>exec script.sh $oldfile $newfile
  </code></pre>
  
  <p>Can anyone point me in the right direction?</p>
  
  <p><strong>EDIT:</strong> To add more detail:</p>
  
  <p>This script will be used for monthly updates of some documents uploaded to a folder, the old documents need to be archived into one compressed file and the new documents, which may have different names, copied over the top of the old. The script needs to be called on a document by document case from another script. The basic flow for this script should be -</p>
  
  <ol>
  <li>The script file should create a new gzip
  archive with a specified name (created from a prefix constant in the script and the current month and year e.g. prefix.september.2009.tar.gz) only if it
  does not already exist, otherwise add to the existing one.</li>
  <li>Copy the old file into the archive.</li>
  <li>Replace the old file with the new one.</li>
  </ol>
  
  <p>Thanks in advance,<br>
  Richard</p>
  
  <p><strong>EDIT:</strong> Added mode detail on the archive filename</p>