A
A
Alexander2014-08-01 18:24:15
Backup
Alexander, 2014-08-01 18:24:15

Bash script. How to delete files?

Hello!
There is a Bash script that makes a backup copy of the database. File name template: ${db}-${DATE}
Could you tell me how to add a script so that it deletes old versions of backups?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sim3x, 2014-08-01
@Losyahka

Filename pattern: ${db}-${DATE}

It's better to prefix DBBACK__${db}-${DATE} or use a separate directory
before inserting, check how the line works in your particular case
find . -type f -file "DBBACK__*" -mtime +1 -exec echo {} \;

S
Sergey Petrikov, 2014-08-01
@RicoX

Delete all files older than 30 days in the current directory.

find ./ -type f -mtime +30 -print0 | xargs -0 rm -f

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question