title: BASH: Copy all files and directories into another directory in the same parent directory
body: <p>I'm trying to make a simple script that copies all of my <code>$HOME</code> into another folder in <code>$HOME</code> called <code>Backup/</code>. This includes all hidden files and folders, and excludes <code>Backup/</code> itself. What I have right now for the copying part is the following:</p>
  
  <pre><code>shopt -s dotglob
  
  for file in $HOME/*
  do
      cp -r $file $HOME/Backup/
  done
  </code></pre>
  
  <p>Bash tells me that it cannot copy <code>Backup/</code> into itself. However, when I check the contents of <code>$HOME/Backup/</code> I see that <code>$HOME/Backup/Backup/</code> exists. </p>
  
  <p>The copy of <code>Backup/</code> in itself is useless. How can I get bash to copy over all the folders except <code>Backup/</code>. I tried using <code>extglob</code> and using <code>cp -r $HOME/!(Backup)/</code> but it didn't copy over the hidden files that I need.</p>