Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 08-10-2003, 03:25 PM   #1
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


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??


#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`
find $i depth -print >> /tmp/backupfiles
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, 11:04 PM   #2
Registered: Jul 2003
Distribution: Suse 10
Posts: 55

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


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 06:19 PM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 01:20 AM
bash script - incrementing a filename in a script tslinux Programming 10 08-06-2003 12:58 AM
bash script brian0918 Programming 7 06-12-2003 07:06 PM
bash script prob: how can i tell the script that a 'dd' has finished? Frustin Linux - General 2 04-02-2003 06:34 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:12 PM.

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