Sponsored Content
Full Discussion: New to shell scripts
Top Forums UNIX for Dummies Questions & Answers New to shell scripts Post 302323521 by paul.duncalf on Monday 8th of June 2009 07:12:14 AM
Old 06-08-2009
New to shell scripts

Hi,

Probably a real easy one for someone...I need to have a scheduled cp job run from crontab to copy certain files and directories to a shared NFS storage.

The script I have works fine, except I need to exclude certain directories to stop issues with symbolic links, can someone explain how this can be done? The code I have so far

Code:
# !/bin/ksh
# Variables
servername=`hostname`
currentdate=`date +20%y%b%d`
backupdest="/solbackups/"$currentdate"/"$servername
src_backupsource="/raid/src"
oldsrc_backupsource="/raid/oldsrc"
oldprogs_backupsource="/raid/oldprogs"
root_backupsource="/"
src=false
oldsrc=false
oldprogs=false
root=false
# Configure Environment
mkdir /solbackups
mount x.x.x.x:/vol/exports/solbackups /solbackups
# Set Backup Requirements
if [ $servername = "servername" ]
then
 src=true
 oldsrc=true
 oldprogs=true
 root=true
fi
if [ $servername = "hercules" ]
then
 src=false
 oldsrc=false
 oldprogs=false
 root=false
fi
# Disk 2 Disk Data Backup Operation
if [ $src = "true" ]
then
 echo "Backing up "$servername" : "$src_backupsource
 mkdir -p $backupdest
 cp -r $src_backupsource $backupdest
fi
if [ $oldsrc = "true" ]
then
 echo "Backing up "$servername" : "$oldsrc_backupsource
 mkdir -p $backupdest
 cp -r $oldsrc_backupsource $backupdest
fi
if [ $oldprogs = "true" ]
then
 echo "Backing up "$servername" : "$oldprogs_backupsource
 mkdir -p $backupdest
 cp -r $oldprogs_backupsource $backupdest
fi
if [ $root = "true" ]
then
 echo "Backing up "$servername" : "$root_backupsource
 mkdir -p $backupdest
 cp -r $root_backupsource $backupdest
fi
echo "Disk 2 Disk Backup Complete"

Any help would be great..

Cheers

Last edited by vidyadhar85; 06-08-2009 at 02:49 PM.. Reason: code tag added
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell scripts

Hi! I have added a line into /etc/profile which looks like- date > $HOME/.lastloggedon This puts a file lastloggedon into everyones directory who has logged in recently. The trouble I am having is getting the information back out. I was hoping there was a command using find which brought... (1 Reply)
Discussion started by: karenshaw
1 Replies

2. UNIX for Dummies Questions & Answers

about shell scripts

Hi, i have made a script which makes some analyses on some differnet hosts. but i have a problem to make this script more quicker ... i would like to enter more a one hosts in the query (in my script are this: Pls enter the Hostname ... read hostname for i in $hostname do echo... (5 Replies)
Discussion started by: scottl
5 Replies

3. Shell Programming and Scripting

shell scripts help

Hi, I am not experienced in shell scripts, I hope someone can give some hint for the following problem I have html file like this <html> <body> Some stuff More stuff <pre> A B </pre> Still more stuff And more <pre> C D </pre> Additional stuff </body> (2 Replies)
Discussion started by: ccp
2 Replies

4. AIX

Difference between writing Unix Shell script and AIX Shell Scripts

Hi, Please give me the detailed Differences between writing Unix Shell script and AIX Shell Scripts. Thanks in advance..... (0 Replies)
Discussion started by: haroonec
0 Replies

5. Shell Programming and Scripting

Need Help With Shell scripts

Hello, I'm very very fresh with unix, and I would like to get familiar with it. I want to know what is Shell scripting and how other programming languages connects with it. And is there any way to learn the shell scripting, with some book and some simulator to practice on. Thanks ahead. (2 Replies)
Discussion started by: holler1
2 Replies

6. Shell Programming and Scripting

Help With Shell Scripts

if I run the below mentioned code, i am getting error. I dunno why. plz help me out this code runs a sql query and sends the result by email #!/bin/ksh # # Purpose: - Report Workflows that have Persistence turned ON echo "Workflow Persistence Report Started: `date '+%Y%m%d_%H%M%S'`" >>... (6 Replies)
Discussion started by: ragha81
6 Replies

7. AIX

Shell Scripts

I would like to seek some expertise of all our AIX experts on board. 1) I would like know how to get a return exit code of a command. I found that there are exist code for each and every command run in AIX but I just can't get the return code from my scripts. A=`cp /home/abc/abc.txt... (7 Replies)
Discussion started by: kwliew999
7 Replies

8. HP-UX

Shell Scripts

I have a text file . Format of text file. djss:xd:78:isdev:"test server" this type of row. (approx 30). I want to display like that 1. djjs@msxd testserver 2. xjfd@msxd devserver 3. 4 select any one from above choice : 1... (5 Replies)
Discussion started by: rastogideepak
5 Replies

9. Shell Programming and Scripting

Shell Scripts

deleted (1 Reply)
Discussion started by: zxc
1 Replies

10. Shell Programming and Scripting

calling 'n' number of shell scripts based on dependency in one shell script.

Hello gurus, I have three korn shell script 3.1, 3.2, 3.3. I would like to call three shell script in one shell script. i m looking for something like this call 3.1; If 3.1 = "complete" then call 3.2; if 3.2 = ''COMPlete" then call 3.3; else exit The... (1 Reply)
Discussion started by: shashi369
1 Replies
SYBASE_CONNECT(3)														 SYBASE_CONNECT(3)

sybase_connect - Opens a Sybase server connection

SYNOPSIS
resource sybase_connect ([string $servername], [string $username], [string $password], [string $charset], [string $appname], [bool $new = false]) DESCRIPTION
sybase_connect(3) establishes a connection to a Sybase server. In case a second call is made to sybase_connect(3) with the same arguments, no new link will be established, but instead, the link identi- fier of the already opened link will be returned. The link to the server will be closed as soon as the execution of the script ends, unless it's closed earlier by explicitly calling sybase_close(3). PARAMETERS
o $servername - The servername argument has to be a valid servername that is defined in the 'interfaces' file. o $username - Sybase user name o $password - Password associated with $username. o $charset - Specifies the charset for the connection o $appname - Specifies an appname for the Sybase connection. This allow you to make separate connections in the same script to the same data- base. This may come handy when you have started a transaction in your current connection, and you need to be able to do a separate query which cannot be performed inside this transaction. o $new - Whether to open a new connection or use the existing one. RETURN VALUES
Returns a positive Sybase link identifier on success, or FALSE on failure. CHANGELOG
+--------+------------------------------------+ |Version | | | | | | | Description | | | | +--------+------------------------------------+ | 5.3.0 | | | | | | | The $new parameter was added. | | | | | 4.2.0 | | | | | | | The $appname parameter was added. | | | | | 4.0.2 | | | | | | | The $charset parameter was added. | | | | +--------+------------------------------------+ EXAMPLES
Example #1 sybase_connect(3) example <?php $link = sybase_connect('SYBASE', '', '') or die("Could not connect !"); echo "Connected successfully"; sybase_close($link); ?> SEE ALSO
sybase_pconnect(3), sybase_close(3). PHP Documentation Group SYBASE_CONNECT(3)
All times are GMT -4. The time now is 12:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy