I need to tar a directory and then copy it to another directory locally
I am trying to tar a directory, and then copy the tar file to another directory locally on the same machine. In the script I am also calling another script to shutdownt eh database prior to tar'ing the files.
Here is what I have for the first job to tar the files and copy them locally # cron script to shutdown database backup files and startup database #!bin/sh echo "SHUTTING DOWN THE DATABASE AND BACKING UP THE FILES COLD " # connect to sqlplus and shutdown database with coldshutdown.sql script cd /mnt/backups/scripts UID_PWD`cat concsub_id` slqplus -u $UID_PWD @coldshutdown.sql if $? = 0 cd /mnt/test/oracle/TEST/db/apps_st !tar -cvzf data.tar.gz data cp data.tar.gz /mnt/backups cd /mnt/apps1/oracle/TEST !tar -cvzf apps.tar.gz apps !tar -cvzf inst.tar.gz inst !tar -cvzf db.tar.gz db cp apps.tar.gz /mnt/backups cp inst.tar.gz /mnt/backups cp db.tar.gz /mnt/backups #connect to sqlplus and startup the database with coldstartup.sql script cd /mnt/backups/scripts UID_PWD 'cat concsub_id' sqlplus -u $UID_PWD @coldstartup.sql if $? = 0 echo "the database has started succesffuly" |
and so ?
:-) |
I don't follow you.......I guess I need to close my if with an fi
|
Hmm, I mean, what is your problem ??
|
I was just asking if anyone see any syntax errors or logical errors, this is my first script in LINUX .....DOS and Windows is where I'm coming from.
|
Hmm, ok, get it, have you run your scrip right now ?
Quickly, you need to close your if sentences by fi (as you said), remove the ! by the full path to your executable (ie tar) and review how a shell handle the if sentence too :) Cheers. |
I have not ran it yet.... updated script below... i was told I needed the ! to run tar commands in shell
# cron script to shutdown database backup files and startup database #!bin/sh echo "SHUTTING DOWN THE DATABASE AND BACKING UP THE FILES COLD " # connect to sqlplus and shutdown database with coldshutdown.sql script cd /mnt/backups/scripts UID_PWD=`cat concsub_id` sqlplus -u $UID_PWD @coldshutdown.sql if $? = 0 cd /mnt/test/oracle/TEST/db/apps_st !tar -cvzf data.tar.gz data cp data.tar.gz /mnt/backups cd /mnt/apps1/oracle/TEST !tar -cvzf apps.tar.gz apps !tar -cvzf inst.tar.gz inst !tar -cvzf db.tar.gz db cp apps.tar.gz /mnt/backups cp inst.tar.gz /mnt/backups cp db.tar.gz /mnt/backups #connect to sqlplus and startup the database with coldstartup.sql script cd /mnt/backups/scripts UID_PWD='cat concsub_id' sqlplus -u $UID_PWD @coldstartup.sql if $? = 0 echo "the database has started successfully" fi echo "shutdown was not successful" fi |
Best use BB code tags:
Code:
#!bin/bash |
All times are GMT -5. The time now is 11:58 PM. |