#!/bin/bash
# 7.4.2017 Stefan Abeln script creation
# 13.4.2017 Changed creation of archive due to new needs for restoring archive to new user
# 15.4.2017 Added check for existing backup and removal if present
# Script creates a backup of the home directory of the student user for later restoring it
echo "If an old backup exists this script will delete it"
if sudo file /root/backup_student.tgz 2>&1 >/dev/null
 then
  sudo rm /root/backup_student.tgz
 fi
cd /home/student
echo "Starting backup"
sudo tar cvzf /root/backup_student.tgz .
echo "Finished backup."
