Sponsored Content
Full Discussion: Backup/restore scripts
Top Forums Shell Programming and Scripting Backup/restore scripts Post 302381063 by boabbyrab on Thursday 17th of December 2009 05:23:39 AM
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!
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

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

8. 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

9. 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

10. 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
ECHO(1) 						    BSD General Commands Manual 						   ECHO(1)

NAME
echo -- write arguments to the standard output SYNOPSIS
echo [-n] [string ...] DESCRIPTION
The echo utility writes any specified operands, separated by single blank (' ') characters and followed by a newline (' ') character, to the standard output. The following option is available: -n Do not print the trailing newline character. This may also be achieved by appending 'c' to the end of the string, as is done by iBCS2 compatible systems. Note that this option as well as the effect of 'c' are implementation-defined in IEEE Std 1003.1-2001 (``POSIX.1'') as amended by Cor. 1-2002. Applications aiming for maximum portability are strongly encouraged to use printf(1) to sup- press the newline character. Some shells may provide a builtin echo command which is similar or identical to this utility. Most notably, the builtin echo in sh(1) does not accept the -n option. Consult the builtin(1) manual page. EXIT STATUS
The echo utility exits 0 on success, and >0 if an error occurs. SEE ALSO
builtin(1), csh(1), printf(1), sh(1) STANDARDS
The echo utility conforms to IEEE Std 1003.1-2001 (``POSIX.1'') as amended by Cor. 1-2002. BSD
April 12, 2003 BSD
All times are GMT -4. The time now is 05:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy