Help with Backup Shell Script

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

  1. The problem statement, all variables and given/known data:

Create a script that will backup all important system files every Friday night and send an email to the administrator stating if the backup was successful or not.

  1. Relevant commands, code, scripts, algorithms:

if/then statement
cp /home /ect /usr /local /opt /var /root /boot
cron job or at command
mail -s 'subject'

  1. The attempts at a solution (include all code and scripts):

Commands listed above but I have not put them all together until I'm sure that I have all the correct commands.

  1. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):

Devry University, Decatur, GA, USA, Professor:Bogoevski, Netw240/ACC_A

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).

First you need a destination for the backups. Let's say it is /backup. It says "important files" and to me that means you pick and choose. For example, out of /etc, maybe passwd, shadow, group, and hosts. There are probably others but all of /etc sounds excessive. Any of /opt also sounds excessive to me. Once the script is working you can tweak the exact file list. Also the exact list will vary from OS to OS and you haven't told us yours.

So it sounds like you cd to /backup, create etc, cd to /backup/etc and copy the files you pick from etc. And repeat this for other directories that have file that you feel are important. cp has an exit status and you will need to check it to see if the cp was successful.

The script should be run out of cron.

I think that this should give you enough ideas to start your script.

I only want to backup files that I would need to restore the system if it went down. The system that would be used is Zorin os4. I am not sure how to break that down further, I know it has something to do with Ubuntu (as you can tell, I am brand new to Linux and don't know very much). In doing my research I learned the TAR commmand will backup only important system files, below is the command; is there anything I would need to change?

tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys /

A tar archive is a better way to go. I wasn't sure if you had encountered tar yet so I didn't mention it. Your backup file, backup.tgz, is going to be created in the current directory. So you need to cd to destination directory first. It is going to be a very large file. Make sure you have plenty of free space in the destination. You are backing up pretty much everything.

You should make sure that you exclude the directory containing backup.tgz. You show an exclude for /backup.tgz. That implies that you plan to put the backup file in the root directory. We usually would put it elsewhere.

Why not use rsync to do your backup ? and you can compress it in a single directory ..

This is what I have so far, but I am still unsure.

1.First, install your cron job by running the following command

# crontab -e
 
0 10 * * 5 tar -cvpzf backup.tar.gz --exclude=/backup.tar.gz --exclude=/proc --exclude=/lost+found --exclude=/sys --exclude=/mnt --exclude=/media --exclude=/dev / 
| mail -s 'System Backup was Successful' myname.hotmail.com 
else
mail -s 'System Backup was Non-Successful' myname.hotmail.com

Can anyone steer me in the right direction?