1833838 Members
2449 Online
110063 Solutions
New Discussion

appending tar backup.

 
SOLVED
Go to solution
Manoj Sivan
Regular Advisor

appending tar backup.

Hi Experts,

I need to take the backup of my rmon log files once in a month. I prefer to append the used tape every month. the directory structure i use to backup is as follows.

drwxrwxrwx 2 sysdba dba 1024 Dec 6 03:24 2005-07-20
drwxrwxrwx 2 oracle dba 1024 Jan 1 22:09 2006-01-01
drwxrwxrwx 2 oracle dba 1024 Jan 2 22:09 2006-01-02
drwxrwxrwx 2 oracle dba 1024 Jan 3 22:09 2006-01-03
drwxrwxrwx 2 oracle dba 1024 Jan 4 22:18 2006-01-04
drwxrwxrwx 2 oracle dba 1024 Jan 5 22:10 2006-01-05
drwxrwxrwx 2 oracle dba 1024 Jan 6 22:10 2006-01-06

So my plan is to take the backup the log directories of dec and delete those from system.So only jan and Feb will be available on system.So i would like to schedule this every month.

Can anyone suggest a script using tar to schedule a cron for this.

Thanks in advance.

Manoj
4 REPLIES 4
Victor Fridyev
Honored Contributor

Re: appending tar backup.

Hi,

If I understood ypur needs correctly, you have to do the following each first day of a month:
BACKDIR=/rmonback
TAPENAME=/dev/rmt/0m
find $BACKDIR -type d -mtime +60 -exec rm -r {} \;
tar cf $TAPENAME $BACKDIR

HTH
Entities are not to be multiplied beyond necessity - RTFM
Senthil Kumar .A_1
Honored Contributor
Solution

Re: appending tar backup.

Hi Manoj,

As per my interpretation, following is the script....

--------------------------------------------

#!/usr/bin/sh
BCK_PARENT_DIR=/oracle/rmonback
TAPEDRIVE=/dev/rmt/0m


cd $BCK_PARENT_DIR

# Backup using append mode,the 2 month prior Dir's with relative path mode(helpful while restoring).
find ./* -type d -prune -mtime +60 | xargs tar rvf $TAPEDRIVE 1> /tmp/`date +%b`_rmonbck.log 2>&1

# Remove the 2 month prior Dir's for clean up, leaving the log files of last 2 months.
find ./* -type d -prune -mtime +60 | xargs rm -rf

--------------------------------------------

You can schedule the script to run once every month say by 1s't day of the month. Ofcourse you can check the log file by name "/tmp/Jan.log" to see the backup activity performed for that month.

Regards,
Senthil Kumar .A
Let your effort be such, the very words to define it, by a layman - would sound like a "POETRY" ;)
Senthil Kumar .A_1
Honored Contributor

Re: appending tar backup.

Hi,

Please check the attached script. The lines are split into 2 ,though it is single line in the display of my previous post.

ftp the script to the unix box and test first. Remove the second "find" command line while testing. Once satisfied, u can use the second "find"command aswell.

Regards,
Senthil Kumar .A
Let your effort be such, the very words to define it, by a layman - would sound like a "POETRY" ;)
Manoj Sivan
Regular Advisor

Re: appending tar backup.

Hi Sentil/Victor

Thanks a lot for the help.

Regards

Manoj