Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I copied this from a blog entry, studied it, tweaked it a bit and more or less it works:

#!/bin/bash

GZ_DATE=`date +%Y%m%d`
GZ_TIME=`date +%H`

BK_PATH=/mnt/usbbk/sql
BK_FILE=$BK_PATH/$GZ_DATE-$GZ_TIME.gz

#
# Find all files older than 7 days (10080 minutes) and remove them
#

find BK_PATH* -type f -mmin +10080 -exec rm {} \;

#
# Dump and gzip export of SQL data
#

mysqldump --lock-all-tables --all-databases -u backup -p backup | gzip > $BK_FILE

However it does not seem to delete backups which are

share|improve this question
    
I'm closing this as it's only about half a post... finish your post and I'll happily re-open it :-) –  voretaq7 May 6 '12 at 2:44
    
It does not delete backups which are what ? –  Iain May 6 '12 at 6:10
add comment

closed as not a real question by voretaq7 May 6 '12 at 2:44

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

3 Answers

Did you mean to post this? It looks unfinished.

It's not deleting files because the line you would expect to delete them - the find command, which executes rm on the matching files it finds - is commented out (starts with a #). It's being ignored.

share|improve this answer
    
The last sentence seems to have been chopped. Weird. In any event, it was of little relevance. It is commented out but even when it is not it still does not seem to delete dates backups? :s –  Alex.Barylski May 6 '12 at 4:27
add comment

Uncomment find BK_PATH* -type f -mmin +10080 -exec rm {} \;

share|improve this answer
add comment

I assume that in the live version of this script, the find is not commented out (commenting a find -exec rm structure out in a pasted script is actually a good idea) ?

share|improve this answer
1  
That would be correct this was done in error as I tested the script. I noticed just now the BK_PATH does not have the $ and no trailing slash is given. I changed that and now I will see what happens :) –  Alex.Barylski May 6 '12 at 4:30
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.