03-11-2004
Backup with shell program and cron job.
Hi,
The object of my program is to take automatic backup on daily basis to different folders. I have created the respective folders. when I execute below given shell program manually it is working perfectly and taking the backup to respective folder.
#!/bin/sh
#script to take backup on day basis, This is going to run from cron job.
#
while :
do
clear
yourch=`date +%u`
case $yourch in
1) exp backuser/backuser@linux1 file=/disk4/backup/Mon/linux1_Mon.dmp log=/disk4
/backup/Mon/linux1_Mon.log full=y direct=Y compress=N rows=N; exit 0;;
2) exp backuser/backuser@linux1 file=/disk4/backup/Tue/linux1_Tue.dmp log=/disk4
/backup/Tue/linux1_Tue.log full=y direct=Y compress=N rows=N; exit 0;;
3) exp backuser/backuser@linux1 file=/disk4/backup/Wed/linux1_Wed.dmp log=/disk4
/backup/Wed/linux1_Wed.log full=y direct=Y compress=N;rows=Y exit 0;;
4) exp backuser/backuser@linux1 file=/disk4/backup/Thu/linux1_Thu.dmp log=/disk4
/backup/Thu/linux1_Thu.log full=y direct=Y compress=N rows=N; exit 0;;
5) exp backuser/backuser@linux1 file=/disk4/backup/Fri/linux1_Fri.dmp log=/disk4
/backup/Fri/linux1_Fri.log full=y direct=Y compress=N rows=N; exit 0;;
6) exp backuser/backuser@linux1 file=/disk4/backup/Sat/linux1_Sat.dmp log=/disk4
/backup/Sat/linux1_Sat.log full=y direct=Y compress=N rows=Y; exit 0;;
esac
done
When the same program kept in cron, it is not working.
IF I EXECUTE NORMAL COMMAND IN THE CRON WITH OUT SHELL THEY ARE WORKING WHEN I KEEP ANY SHELL PROGRAMS, THEY ARE NOT WORKING.
0 23 * * * /home/oracle/backup/backup.sh
> /home/oracle/backup/backup.log
The backup.log file is creating with 0 bytes.
Please help me in solving this problem.
With Regards
Varma.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Just I'm trying to find script, which will do the following job:
1. as a CRON-Job it shoult
a) delete files which will be either older than 24 hours or
b) all files within
a) a directory deleting recursive
b) only a special directory.
2. write an error-/Delete_log... (9 Replies)
Discussion started by: ManfredWL
9 Replies
2. UNIX for Dummies Questions & Answers
My shell script runs fine both as a cron job and when i issue it.
However, I wish to differentiate when it runs as a cron-job so the "echo" statements are not issued (they get mailed to me, which i don't want).
I tried checking $USER but since the cron was created in my user that does not... (5 Replies)
Discussion started by: sentinel
5 Replies
3. Shell Programming and Scripting
Hi I have a website that is having problem with cron jobs...
I have a cron job set up to go to a page with this code...
<?
include('config.php');
if($_sys->bible_email_frequency == 'DAILY')
{
$u = new user();
$u->send_bible_email();
}
?>
If i send my browser to this page... (2 Replies)
Discussion started by: whybelieve
2 Replies
4. Shell Programming and Scripting
Hey Guys,
i was trying out a shell script which has to remove a file for every 90 mins. this is the code i came up with .
$ crontab -e file1
file1 contains
30 1 * * * * rm -r /folder1/folder2/somefile.txt
Now i need the cron to run for every 90 mins. the problem with this is... (8 Replies)
Discussion started by: Irishboy24
8 Replies
5. Shell Programming and Scripting
i have just installed a cron job to run at 3 in the morning once a week. It's difficult for me to test if it works because the email backup program takes the email service down before running the backup. I wondered if i could ask you gurus if this would work?
0 3 * * 0 ... (1 Reply)
Discussion started by: timgolding
1 Replies
6. Solaris
Hi,
The following shell script runs without any problem when executed manulally.
USED=$(df -h /arch | tail -1 | awk '{print $5}' | cut -d '%' -f 1)
if
then
find /arch/AUBUAT/ -type f -mtime +0 | xargs rm
find /arch/AUBMIG/ -type f -mtime +0 | xargs rm
fi
But the same gives below... (6 Replies)
Discussion started by: ksadiq79
6 Replies
7. UNIX for Dummies Questions & Answers
Hi am newbie for unix shell..
how to create a cron job for my already created shell script.:confused:
Thanks! (1 Reply)
Discussion started by: vidhyaS
1 Replies
8. Shell Programming and Scripting
Dear experts,
I have this cronjob
* */2 * * * $path/supervisor.sh The supervisor script is checking another script, which initializes the final scripts in multiple directories.
Note that the supervisor script runs without the cronjob.
In each directory, I have the following script:
... (2 Replies)
Discussion started by: TheTransporter
2 Replies
9. Shell Programming and Scripting
how to write a code using shell scripting to refire a back up job if it fails with an error code of 196? (7 Replies)
Discussion started by: Pawan Ramnani
7 Replies
10. Shell Programming and Scripting
I am trying a cron on root user to backup to tape using TAR command
here is the cron entry
11 08 * * 6 /erdhot1cron 2>&1 >> /test3/scripts/dba/erdhot1cron.log
here is script inside - edhot1cron
#!/bin/bash
vsysdt=`date +%d%m%y`
date
tar -cvf /dev/st0... (4 Replies)
Discussion started by: vijaymec50
4 Replies
LEARN ABOUT DEBIAN
storebackupdel
STOREBACKUPDEL(1) User Contributed Perl Documentation STOREBACKUPDEL(1)
NAME
storeBackupDel.pl - this program deletes backups created by storeBackup
SYNOPSIS
storeBackupDel.pl [-f configFile] [--print]
[-b backupDirectory] [-S series] [--doNotDelete]
[--deleteNotFinishedDirs] [-L lockFile]
[--keepAll timePeriod] [--keepWeekday entry] [--keepFirstOfYear]
[--keepLastOfYear] [--keepFirstOfMonth] [--keepLastOfMonth]
[--keepFirstOfWeek] [--keepLastOfWeek]
[--keepDuplicate] [--keepMinNumber] [--keepMaxNumber]
[-l logFile
[--plusLogStdout] [--suppressTime] [-m maxFilelen]
[[-n noOfOldFiles] | [--saveLogs]
[--compressWith compressprog]]
WARNING
!!! USAGE IN PARALLEL WITH storeBackup.pl CAN DESTROY YOUR BACKUPS !!!
OPTIONS
--file, -f
configuration file (instead of parameters)
--print
print configuration read from configuration file and stop
--backupDir, -b
top level directory of all backups (must exist)
--series, -S
directory of backup series
same parameter as in storeBackup / relative path
from backupDir, default is 'default'
--lockFile, -L
lock file, if exists, new instances will finish if
an old is already running, default is $lockFile
--doNotDelete
test only, do not delete any backup
--deleteNotFinishedDirs
delete old backups which where not finished
this will not happen if doNotDelete is set
--keepAll
keep backups which are not older than the specified amount
of time. This is like a default value for all days in
--keepWeekday. Begins deleting at the end of the script
the time range has to be specified in format 'dhms', e.g.
10d4h means 10 days and 4 hours
default = $keepAll;
--keepWeekday
keep backups for the specified days for the specified
amount of time. Overwrites the default values chosen in
--keepAll. 'Mon,Wed:40d Sat:60d10m' means:
keep backups of Mon and Wed 40days + 5mins
keep backups of Sat 60days + 10mins
keep backups of the rest of the days like spcified in
--keepAll (default $keepAll)
if you also use the 'archive flag' it means to not
delete the affected directories via --keepMaxNumber:
a10d4h means 10 days and 4 hours and 'archive flag'
e.g. 'Mon,Wed:a40d Sat:60d10m' means:
keep backups of Mon and Wed 40days + 5mins + 'archive'
keep backups of Sat 60days + 10mins
keep backups of the rest of the days like specified in
--keepAll (default $keepAll)
--keepFirstOfYear
do not delete the first backup of a year
format is timePeriod with possible 'archive flag'
--keepLastOfYear
do not delete the last backup of a year
format is timePeriod with possible 'archive flag'
--keepFirstOfMonth
do not delete the first backup of a month
format is timePeriod with possible 'archive flag'
--keepLastOfMonth
do not delete the last backup of a month
format is timePeriod with possible 'archive flag'
--firstDayOfWeek
default: 'Sun'. This value is used for calculating
--keepFirstOfWeek and --keepLastOfWeek
--keepFirstOfWeek
do not delete the first backup of a week
format is timePeriod with possible 'archive flag'
--keepLastOfWeek
do not delete the last backup of a week
format is timePeriod with possible 'archive flag'
--keepDuplicate
keep multiple backups of one day up to timePeriod
format is timePeriod, 'archive flag' is not possible
default = $keepDuplicate;
--keepMinNumber
Keep that miminum of backups. Multiple backups of one
day are counted as one backup. Default is 10.
--keepMaxNumber
Try to keep only that maximum of backups. If you have
more backups, the following sequence of deleting will
happen:
- delete all duplicates of a day, beginning with the
old once, except the oldest of every day
- if this is not enough, delete the rest of the backups
beginning with the oldest, but *never* a backup with
the 'archive flag' or the last backup
--keepRelative, -R
Alternative deletion scheme. If you use this option, all other
keep options are ignored. Preserves backups depending
on their *relative* age. Example:
-R '1d 7d 2m 3m'
will (try to) ensure that there is always
- One backup between 1 day and 7 days old
- One backup between 5 days and 2 months old
- One backup between 2 months and 3 months old
If there is no backup for a specified timespan
(e.g. because the last backup was done more than 2 weeks
ago) the next older backup will be used for this timespan.
--logFile, -l
log file (default is STDOUT)
--plusLogStdout
if you specify a log file with --logFile you can
additionally print the output to STDOUT with this flag
--suppressTime
suppress output of time in logfile
--maxFilelen, -m
maximal length of file, default = 1e6
--noOfOldFiles, -n
number of old log files, default = 5
--saveLogs
save log files with date and time instead of deleting the
old (with [-noOldFiles])
--compressWith
compress saved log files (e.g. with 'gzip -9')
default is 'bzip2'
COPYRIGHT
Copyright (c) 2003-2008 by Heinz-Josef Claes (see README). Published under the GNU General Public License v3 or any later version
perl v5.14.2 2012-06-16 STOREBACKUPDEL(1)