hi people i am in need of some assistance here hoping to star a linux course in january to wanted to get some experiance before starting so got a hold of some old assessments from a mate at college so just working through them in my spare time for the past 8 weeks or so and this is the final ? that i am stuck with this it in in full:
a software company has established standards with regards to the naming and organisation of files in its linux based filestore. in particular, users are directed to store files of a particular type in the same directory, for example, users sre instructed to store all word processor files in a directory named wp. for the purpose of this exercise therea re 3 types of file available - wordprocessing, spreadsheet and picture files.
up until now house keeping practices have been a bit haphazard and it has been upto the individual user as to the manner in which they organise back up of files, if indeed this is done at all. therefore the company wishes to to develop a new utility which will aid the users in backing up and restoring files in their own personal directory area. in doing this development, it should be recognised that script files are treated like any other i.e. they should be stored in a directory called scriptfiles.
only one utility is to be developed
the utility will give the user the option to back up or restore a set of files
the utility will give the user the ability to specify which type of file is to be used in a particular back up or restore session.
the utility should be robust with respect to files and directories and the possible overwriting of files; the utility should provide help to allow the novice user to make use of the utility.
dont really understand it to tell the truth but its the last paper i have left before starting from scratch again
thank you
Take a look at existing utilities, i think mostly at rsync which is complete and very versatile. You can also search on the web for backup utilities, search engines are your friends
Then you can wrap some scripting around it to make it more personnal ans user friendly.
For that purpose, if you're beginner in shell scripting you can write it in pseudo-code to set the logic of the application. Minimum requirements is to have an idea of the behaviour of tests and loops:
- if... ; then...; else ...; fi
- while ... ; do ....; done
- for ... in ... ; do.... ; done...
For the remaining, if you don't know the syntax, just respect the logic and use common words.
Begin your lines of pseudo-code by '#' so that they can remain as comments in the script for further debugging.
Hope this can help you.
hi guys this is what i have got so far but dont know if i am getting it right:
#!/bin/bash
#####################################################
###backup blah blah
#################################
clear
VALID_PATH=0
BACKUP_FILE=backup$(date +%Y%m%d).tgz
BACKUP_DIR=/backup/
[[ ! -d $BACKUP_DIR ]] && mkdir -p $BACKUP_DIR
echo 1 Perform Backup
echo 2 Restore From Backup
echo 3 Exit Program
read OPTION
case $OPTION in
"1") echo You picked 1
echo backup files
read SOURCE
while [[ $VALID_PATH -eq 0 ]]
do
if [[ -d "$SOURCE" ]]
then
VALID_PATH=1
BACKUP_FILE="$BACKUP_DIR""$BACKUP_FILE"
echo all files
echo backed up to $BACKUP_FILE
else
echo this is invalid
echo please retry
read SOURCE
if [ "$SOURCE" == q]; then
echo Goodbye!
exit 0
fi
fi
done
tar -czf $BACKUP_FILE $SOURCE && echo "Backup Done" || echo "Backup Failed"
;;
"2") echo you chose 2
echo restore?
echo backup directory contents
ls $BACKUP_DIR
echo enter the name
read RESTORE_FILE
RESTORE_FILE="$BACKUP_DIR""$RESTORE_FILE"
until [[ $VALID_PATH != 0 ]]
do
if [[ -f $RESTORE_FILE ]]
then
VALID_PATH=1
else
echo FAIL
echo Backup directory contents
echo
ls "$BACKUP_DIR"
echo
echo "q to quit!"
read RESTORE_FILE
if [[ "$RESTORE_FILE" == "q" ]]; then
echo
echo goodbye!
exit 0
fi
RESTORE_FILE="$BACKUP_DIR""$RESTORE_FILE"
fi
done
echo
echo the file $RESOTER_FILE will be used to perform
echo
tar -xvf $RESTORE_FILE
;;
"3") echo goodbye
exit 0;;
esac
now when i run it i get the 3 options. so pick option 1
and the reply backup files appears and then nothing happens, so if i choose another option it say this is invalid please retry. pick another option and it says: script: line 42: [: missing `]'
if i press 3 to quit it comes up with that line again and the only way to quit is by rage quit. now from the original question i think the file types have to backup into there own directories i.e. spreadsheet files into speadsheet directory (i could be wrong but i think thats what i am reading) and how would i do that.
sorry for the all questions but just need all the help i can get.
cheers