title: Bash Script backup
body: <p>I am trying to create a bash script, which takes as an argument, a txt file which has a list of namesand backs up the users home directories as follows:</p>
  <p>Each home directory contains a .backup, with the files to be backed up (relative paths from home directory) one per line. If a .backup file is not there, one is created.</p>
  <p>The file /var/backup.tar.gz, if existing, should be extracted to /tmp/backup.</p>
  <p>Each relevant file in /home/ should be compared with those in the /tmp/backup/ directory with the same name, and if different, the previous version must be renamed and replaced. If filename.1 exists, filename should be renamed to filename.2 or 3 etc. and the file copied from the home directory.</p>
  <p>then finally the will be backed up to  /var/backup.tar.gz</p>
  <p>Struggling to add the .backup file and completing the comparison. Have been able to have the script extract the user name by using command -</p>
  <p>Run Script - ./backupUSER.sh $(cat names.txt)</p>
  <pre><code> #!/bin/bash
  
   user=&quot;$1&quot;
   input=/home/$1
   output=/tmp/backup/$1_home.tar.gz
  
   tar -czf $output $input
   echo &quot;Backup of $1 completed! Details about the output backup file:&quot;
   ls -l $output
  </code></pre>