Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Backup Rationalisation Script - Help Required Post 302553211 by jeked on Wednesday 7th of September 2011 04:20:51 AM
Old 09-07-2011
Update on code

Ok so i took into account what you siad about rsync and managed something but now i want to finish what i started...after redefining what i need to do to myself i came to the following:

This is what i need processFolder() to do :P
Code:
#process folder(folder) {
#       for all the entreies in this folder
#               if current_thing = file
#                       if file existis on client
#                               if size is no same
#                                       flag error
#                               else
#                                       OK
#                       else
#                               flag for deletion
#               elif current_thing = dir
#                       process folder(current_thing)
#               elif
#                       error - not file or folder
#       fi
#}

And this is what i currently have....

Code:
#!/bin/sh

processFolder() {

  while ($BF_VAL="1") do
                if [ -f $BF_VAL ]
                 then
                        echo "file"
                else
                        echo "dir"

fi
}

echo "Initilising variables"

#CF = Client File
#BS = Backup Folder
#D = Dry-run

CF_ARG=0
CF_VAL=
BF_ARG=0
BF_VAL=
D_ARG=0

parseArgs()
{
while [ $# -gt 0 ]
do
    case "$1" in
                -d)   D_ARG=1;;
        -c)   CF_ARG=1; CF_VAL=$2; shift;;
        -b)   BF_ARG=1; BF_VAL=$2; shift;;
        ?) printHelp;;
        *) echo "$1 not an option"; printHelp;;
    esac
    shift
done
}

printHelp()
{
        echo "Usage: ./test-v2.sh -d -c [filename] -b [folder location]"
                echo ""
                echo "-d = Dry-run."
                echo "          ie. Run through the program as normal but only output a file with
                the changes that could be made."
                echo ""
                echo "-c = Client File input."
                echo "          ie. Supply the location and name of the previously generated client
                file list."
                echo ""
                echo "-b = Backup Folder Location."
                echo "          ie. Supply the location of where the backup is currently stored."
}

# main starts here

parseArgs $*

echo "Reading client file " $CF_VAL
echo "Reading backup folder " $BF_VAL
processFolder $BF_VAL

Any furthur input on this? ASAP but i know you all have lives Smilie

Regards,
John
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script help required!

Hi there, i am trying to create a script that checks for the existence of users on the system, if they exist then their details should print on the screen with a message that the id is in use. I am having a bit of trouble with it. Any ideas? Cheers Kev! (8 Replies)
Discussion started by: kev112
8 Replies

2. Shell Programming and Scripting

script required

The line is like this +abc+def+mgh+ddsdsd+sa i.e. words seperated by +. There is a plus in the beginning. i want to conver this line to abc, def, mgh, ddsdsd, sa please provide the logic in the form of a shell script Thanks in advance (13 Replies)
Discussion started by: skyineyes
13 Replies

3. Shell Programming and Scripting

Getting required fields from a test file in required fromat in unix

My data is something like shown below. date1 date2 aaa bbbb ccccc date3 date4 dddd eeeeeee ffffffffff ggggg hh I want the output like this date1date2 aaa eeeeee I serached in the forum but didn't find the exact matching solution. Please help. (7 Replies)
Discussion started by: rdhanek
7 Replies

4. Shell Programming and Scripting

Help required to get a script

Hi Experts, I am very beginner in Bash Shell Scripting. Can anyone please guide me to create a script which should show the most busy file systems in sort basis as there are a lot of file systems on the server. I was told this task to be done by my IT lead and I must have to do this in... (3 Replies)
Discussion started by: naw_deepak
3 Replies

5. Shell Programming and Scripting

rsync backup mode(--backup) Are there any options to remove backup folders on successful deployment?

Hi Everyone, we are running rsync with --backup mode, Are there any rsync options to remove backup folders on successful deployment? Thanks in adv. (0 Replies)
Discussion started by: MVEERA
0 Replies

6. Shell Programming and Scripting

Help with Backup Shell Script for Network Device Configuration backup

HI all, im new to shell scripting. need your guidence for my script. i wrote one script and is attached here Im explaining the requirement of script. AIM: Shell script to run automatically as per scheduled and backup few network devices configurations. Script will contain a set of commands... (4 Replies)
Discussion started by: saichand1985
4 Replies

7. UNIX for Dummies Questions & Answers

Perl Script:how to find how many parameters are required to run the script

How to find how many parameters are required to run a Perl script? (1 Reply)
Discussion started by: Lakshman_Gupta
1 Replies

8. AIX

GTAR - new ways for faster backup - help required

We are taking backup of our application data(cobol file system, AIX/unix) before and after EOD job runs. The data size is approximately 260 GB in biggest branch. To reduce the backup time, 5 parallel execution is scheduled through control-m which backups up the files in 5 different *.gz. The job... (2 Replies)
Discussion started by: Bharath_79
2 Replies

9. AIX

GTAR - new ways to faster backup - help required

We are taking backup of our application data(cobol file system, AIX/unix) before and after EOD job runs. The data size is approximately 260 GB in biggest branch. To reduce the backup time, 5 parallel execution is scheduled through control-m which backups up the files in 5 different *.gz. The job... (8 Replies)
Discussion started by: Bharath_79
8 Replies

10. Shell Programming and Scripting

Help required to get a backup script working

Hi all I have a unix based firewall, which creates a daily backup file on the device. I need a script to scp this file over to a remote server. I can get this working daily using a basic script and a cron job. However, I only want it to send the latest config back up file and currently... (4 Replies)
Discussion started by: jimmyzoom
4 Replies
echo(1B)					     SunOS/BSD Compatibility Package Commands						  echo(1B)

NAME
echo - echo arguments to standard output SYNOPSIS
/usr/ucb/echo [-n] [argument] DESCRIPTION
echo writes its arguments, separated by BLANKs and terminated by a NEWLINE, to the standard output. echo is useful for producing diagnostics in command files and for sending known data into a pipe, and for displaying the contents of envi- ronment variables. For example, you can use echo to determine how many subdirectories below the root directory (/) is your current directory, as follows: o echo your current-working-directory's full pathname o pipe the output through tr to translate the path's embedded slash-characters into space-characters o pipe that output through wc -w for a count of the names in your path. example% /usr/bin/echo "echo $PWD | tr '/' ' ' | wc -w" See tr(1) and wc(1) for their functionality. The shells csh(1), ksh(1), and sh(1), each have an echo built-in command, which, by default, will have precedence, and will be invoked if the user calls echo without a full pathname. /usr/ucb/echo and csh's echo() have an -n option, but do not understand back-slashed escape characters. sh's echo(), ksh's echo(), and /usr/bin/echo, on the other hand, understand the black-slashed escape characters, and ksh's echo() also understands a as the audible bell character; however, these commands do not have an -n option. OPTIONS
-n Do not add the NEWLINE to the output. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWscpu | +-----------------------------+-----------------------------+ SEE ALSO
csh(1), echo(1), ksh(1), sh(1), tr(1), wc(1), attributes(5) NOTES
The -n option is a transition aid for BSD applications, and may not be supported in future releases. SunOS 5.11 3 Aug 1994 echo(1B)
All times are GMT -4. The time now is 08:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy