LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   bash script help (https://www.linuxquestions.org/questions/linux-newbie-8/bash-script-help-80681/)

klfreese 08-10-2003 02:25 PM

bash script help
 
here is the senerio (Im very confused)
Ive only had 6 linux classes and the teacher is not that helpfull.

I need to write a script in bash called (rootbackup) that will back-up,compress, and restore critical system and user files.

I need to create a file in roots home dir called (critical-files) using VI, In this file, store the fully qualified path and file names of the files to be backed up. The files are

/etc/httpd/conf/*
/home/*
/etc/services
/etc/xinetd/*

Each feat ure should be on its own line

in the script, use a for-loop to process the file by reading each line of the file. Use the (1) tar or (1L) cpio command to collect the files. Pipe the files in to (1) gzip to compress the archive. Write the output file into the roots home dir as backup. {PID} where PID = process ID of the running shell script. Send all output from the shell script to a log file in roots home dir called (backup.log). When the process completes successfully, send root an email reporting that the backup was taken. In the email, list the name of the back-up file.

The script should take the name of the configuration file, (critical-files) as a command line parameter. If the file is not given at the command line, Display a help message.


( post #11)

Am i getting close ???
any suggestions??

#!/bin/bash
#rootbackup

#This program backs up critical files

[ "$#" -ne 1 ] && echo "Usage: rootbackup <input file list>" && exit 1
[ -f backup.[0-9]* ] && rm backup.[0-9]*
[ -f /tmp/backupfiles ] && cat /dev/null > /tmp/backupfiles

#
for i in `cat $1`
do
find $i depth -print >> /tmp/backupfiles
done
#
cat /tmp/backupfiles | cpio -o 2>backup.log | gzip >> /backup.$$
msg=`echo \`ls backup.[0-9]*\``
echo "back-up file name is $msg" > junk
mail root <junk
rm junk

klfreese 08-10-2003 10:04 PM

Can i get some help please


All times are GMT -5. The time now is 07:27 PM.