Backup/restore scripts


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Backup/restore scripts
# 1  
Old 12-15-2009
Backup/restore scripts

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
# 2  
Old 12-15-2009
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 Smilie
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.
# 3  
Old 12-17-2009
backup/restore script

hi guys this is what i have got so far but dont know if i am getting it right:

Code:
#!/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

Last edited by Scott; 12-17-2009 at 06:28 AM.. Reason: Code tags, please!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Backup / Restore

Hi, I need to back up a RH file system (96G). The files are oracle .dbf format some of which are 5G in size. I know that tar has got a size restriction of 2G so I cannot use this. Can anyone recommend an alternative way of backuping up this FS? I have been looking at dump but this... (6 Replies)
Discussion started by: Duffs22
6 Replies

2. Shell Programming and Scripting

scripts to Initialise,backup,restore,delete and empty

you are to write scripts for a customer that would require a system enable the backing up of files and directories. The script should (these names should be used): 1. INITIALISE: Initialise the directory for the backup(called backup and should be in the home directory) and any other... (1 Reply)
Discussion started by: babby01
1 Replies

3. AIX

Backup and restore

Hi experts, i got a question. i have a production server with two Volume Group(VG) which are rootvg and datavg. Both of these VGs are 256 PP SIZE. On Disaster Recovery Server (DR server) contains two empty hardisks for restoring rootvg and datavg from production server. This two hardisks are... (7 Replies)
Discussion started by: polar
7 Replies

4. Emergency UNIX and Linux Support

DD command to backup and restore

Hi, Currently I have 2 servers. 1 is already installed with RHEL4(withmyapplications) and the other one is still brand new. My question is, is it possible to use DD command to backup the whole harddrive for the RHEL4 server and restore it to the new brand server so that I do not have to... (3 Replies)
Discussion started by: flekzout
3 Replies

5. Shell Programming and Scripting

Backup and restore in unix

Hello everybody, i am trying to make a script in UNIX to backup some compressed files to a tape drive. The thing is that i cannot use cpio command because some of these files are greater than 2GB. so i think the only solution left is backup command. to restore the files i should use the... (6 Replies)
Discussion started by: omonoiatis9
6 Replies

6. Solaris

Full backup and Restore

Dear All ; first how are you every body I'm just subscribed in your forum and i hope i found what i searched for along time . I'm not a Solaris specialist but i read more to build a Network Management Station depends on Solaris as OS and it is working good now . my problem is how to perform... (16 Replies)
Discussion started by: Basha
16 Replies

7. HP-UX

F-Backup restore

Hello! i have a blank harddrive and a complete tape backup of the workstation. the backup is made with F-Backup. Now my question is: how can i restore my workstation? thanks for every idea! paul tittel hup-si (3 Replies)
Discussion started by: paultittel
3 Replies

8. AIX

Backup and restore

I have several H80 machines, all with AIX 4.3.3. On these machines I have mksysb running for rootvg backups and savevg for non-rootvg backups. I'm trying to get a list of files on the tapes, but I can't seem to do it with tar for the mksysb images. I keep getting the directory checksum errors?... (3 Replies)
Discussion started by: uXion
3 Replies

9. Solaris

Backup / restore

Hi.... everyone could help me to understand how to do a backup of my servers .. operating systems is sun solaris 8 . I have some question about .... 1) Is better backup phisical disk or partition ??? i sow the command is ufsdump 0cfu /expbck/bcksunver/c0t0d0s5 dev/dsk/c0t0d0s5 to... (4 Replies)
Discussion started by: tt155
4 Replies

10. Solaris

Why is restore slower than backup?

After my big disaster, I'm restoring from tape on my Sun box. This is the second time I've used 'ufsrestore' with this DEC TZ88 SCSI DLT drive. The last time was for a migration from one box to another. Both the last time and this time, the restore has taken a hell of a lot longer than the... (4 Replies)
Discussion started by: deckard
4 Replies
Login or Register to Ask a Question