LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-10-2003, 02:25 PM   #1
klfreese
Member
 
Registered: Jul 2003
Distribution: Suse 10
Posts: 55

Rep: Reputation: 15
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
 
Old 08-10-2003, 10:04 PM   #2
klfreese
Member
 
Registered: Jul 2003
Distribution: Suse 10
Posts: 55

Original Poster
Rep: Reputation: 15
Can i get some help please
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash script Linh Programming 4 04-21-2004 05:19 PM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 12:20 AM
bash script - incrementing a filename in a script tslinux Programming 10 08-05-2003 11:58 PM
bash script brian0918 Programming 7 06-12-2003 06:06 PM
bash script prob: how can i tell the script that a 'dd' has finished? Frustin Linux - General 2 04-02-2003 05:34 AM


All times are GMT -5. The time now is 08:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration