LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 04-20-2007, 06:11 PM   #1
JustinK101
Member
 
Registered: Jan 2007
Posts: 55

Rep: Reputation: 15
Talking Automatically Purge Backup Files Off Thumb Drive


Hello, we have a thumb drive attached to a CentOS box and mysql backups are automatically saved to the thumb drive. Is there a way to automatically purge backup files if they are older than say 15 days? I suppose I would need to write a script for this.

The format of the mysql dump files are:

Backup_20070420_0015.sql

Thanks for the help.
 
Old 04-21-2007, 03:58 AM   #2
fukawi2
Member
 
Registered: Oct 2006
Location: Melbourne, Australia
Distribution: ArchLinux, ArchServer, Fedora, CentOS
Posts: 448

Rep: Reputation: 34
Code:
find /mnt/thumb -mtime +15 -iname Backup\*.sql -exec rm -rf {} \;
 
Old 04-23-2007, 11:18 AM   #3
JustinK101
Member
 
Registered: Jan 2007
Posts: 55

Original Poster
Rep: Reputation: 15
Ok, so do I just put that in a file, which is rwxr-x-r-x and then add to the cronmanager?
 
Old 04-23-2007, 11:39 AM   #4
JustinK101
Member
 
Registered: Jan 2007
Posts: 55

Original Poster
Rep: Reputation: 15
Also, do I need to define what shell I want to use?
 
Old 04-23-2007, 05:46 PM   #5
fukawi2
Member
 
Registered: Oct 2006
Location: Melbourne, Australia
Distribution: ArchLinux, ArchServer, Fedora, CentOS
Posts: 448

Rep: Reputation: 34
You could make it in to a cron script if you like.

Something as simple as this would work:
Code:
#!/bin/bash

find /mnt/thumb -mtime +15 -iname Backup\*.sql -exec rm -rf {} \;
You might like to add a check to see if the USB Key is actually mounted:
Code:
#!/bin/bash

SCRUBDIR='/mnt/thumb'

# Check if it's mounted first
MOUNTED=`cat /etc/mtab | grep $SCRUBDIR`
if [ ! -z "$MOUNTED" ] ; then
	find $SCRUBDIR -mtime +15 -iname Backup\*.sql -exec rm -rf {} \;
fi
 
  


Reply


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
Mepis, copy files to thumb drive, files deleted? vremenno Linux - Newbie 6 09-15-2006 11:21 PM
LXer: Backup MySQL databases, web server files to a FTP server automatically LXer Syndicated Linux News 0 08-11-2006 09:54 PM
Purge duplicate files in one directory smudge|lala Linux - General 8 03-30-2006 08:08 PM
help saving files and moving with thumb drive bullet_hole Linux - General 1 01-21-2006 09:29 PM
Backup files to usb thumb - runlevel 3 scriptn00b Linux - Newbie 3 09-18-2005 03:17 PM


All times are GMT -5. The time now is 09:22 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration