[CentOS] Bash Script help...

Fri May 8 05:12:59 UTC 2009
Jason Todd Slack-Moehrle <mailinglists at MailNewsRSS.com>

Hi All,

I need to write a script that I will manually start (or a cron job in  
future) but I need it to do a number of things in order one after  
another.  How do i do that so everything gets dont as the steps depend  
on each other.

Example:

cd /system_backups/

tar cvf apache-conf.tar /etc/httpd/conf/*
gzip -v9 apache-conf.tar

tar cvf apache-data.tar /var/www/*
gzip -v9 apache-data.tar

then last step...
tar cvf <current_date>-system_backup.tar <all> the gzip files above
gzip -v9 <current_date>-system_backup.tar

scp <current_date>-system_backup.tar.gz user at 10.0.0.1:/.
etc...etc....

My questions:
1. How do I execute each statement and make sure subsequent statements  
are not executed until the previous is done?

2. How do I error check so if a step fails the script stops?

3. Since I run an SMTP Server on this box can I e-mail myself from  
bash the nightly results?

4. when I want to run the scp to send over the file to another machine  
for safety, how can I have it know the password to the machine I am  
scp'ing to?

My mind is going crazy sort of with the things that I could do to  
protect myself in case of a system failure and making restoring easier.

Can anyone provide insight for me?

-Jason