LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-27-2009, 07:46 AM   #1
franjo124
LQ Newbie
 
Registered: Mar 2008
Posts: 14

Rep: Reputation: 0
Smile Removing obsolete backup files and containing directory


Hi, This is my first post in LQ

I'm an Oracle DBA. My database writes backup files to ../Backup area. After writing those file to tape i would like to remove them from disk. That would be simple for me. But I want to keep last five (5) sets of files on disk for faster restore (please All mighty never force me to need and use it).
I need a script that would do the chore for me.
Directory structure is something like this
../Backup/db1/before_today/20090310
../Backup/db1/before_today/20090311
../Backup/db1/before_today/20090312
../Backup/db2/before_today/20090310
../Backup/db2/before_today/20090311
../Backup/db2/before_today/20090312

I want to delete (rm -r) directory ../20090312 for db1 and db2 every day at 7:00

I would appreciate help from linux expert

Regards Franjo
 
Old 03-27-2009, 01:13 PM   #2
openSauce
Member
 
Registered: Oct 2007
Distribution: Fedora, openSUSE
Posts: 252

Rep: Reputation: 39
It looks like you want

Code:
rm -r /path/db{1,2}/before_today/$(date --date='3 days ago' +%Y%M%d)
Be sure to test it with
Code:
echo rm -r /path/db{1,2}/before_today/$(date --date='3 days ago' +%Y%M%d)
to make sure it's doing the right thing.

Put the above command in your crontab - see man crontab for details.
 
Old 03-30-2009, 08:05 AM   #3
franjo124
LQ Newbie
 
Registered: Mar 2008
Posts: 14

Original Poster
Rep: Reputation: 0
Thanks, I just needed what I got.
I applied solution, it works and is small and beautiful.

Regards
Franjo
 
  


Reply

Tags
cleanup


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
svn restore directory to a revision also removing files not part of revision Four Linux - Software 1 03-03-2009 05:18 PM
Removing Backup(~) files in fc4 coolguy_iiit Linux - Newbie 9 07-31-2006 12:45 AM
Removing files wihtout removing containing Direcotry caps_phisto Linux - General 2 10-07-2004 09:16 AM
removing obsolete files in APT m_yates Debian 1 11-15-2003 07:57 PM
Removing Obsolete Software JHuizingh Linux - General 4 02-26-2002 03:17 PM


All times are GMT -5. The time now is 05:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration