Backup script

Hey there,

I'm attempting to create a shell script using Ubuntu that will take one optional argument (which in this case is a path to a directory to backup) and will back up (by using the tar command) the chosen directory which is the /home. And i want, after tar'ing the home directory, for it to save the output in /var/backups with the file name as the date and the username. I also want to create it so that if an argument to the script is not supplied, it backs up the current users home directory. I also want the script to print an error message and exits the script if the directory could not be found.

I'm very new to this so I was just hoping I could get pointed in the right direction!

Cheers.

I will tell you what tools you will need.
man tar, man date, whoami, file/dir checking conditions, if-else, echo, exit, cp or mv
Algo will be something like this...

  1. Check the username supplied or use whoami to get the current user name
  2. get the date using date command
  3. check if dir exist using (file/dir checking conditions) in /var/backups using if-else
  4. if exist, tar all the files in /home/user
  5. use mv or cp to copy tar to /var/backups
  6. Give apporpriate message(s) and exit.