Remove older backups like 1 month

Gabriel9999

Member
Joined
Mar 12, 2019
Messages
38
Reaction score
4
Credits
130
I have some backup files which are created in a Daily manner. After some time they take a lot of space and i want to delete them according to their time stamp like delete 1 month olders. Thanks.
 


Condobloke

Well-Known Member
Joined
Apr 30, 2017
Messages
3,718
Reaction score
3,324
Credits
18,151
G'day Gabriel, and Welcome to linux.org

What was used to make these backups?

Where are they stored ?.....same hard drive as the OS?...or an external hard drive ?

Which OS are you running?....which desktop etc
 
OP
G

Gabriel9999

Member
Joined
Mar 12, 2019
Messages
38
Reaction score
4
Credits
130
G'day Gabriel, and Welcome to linux.org

What was used to make these backups?

Where are they stored ?.....same hard drive as the OS?...or an external hard drive ?

Which OS are you running?....which desktop etc


Hi,
Same hard drive as the OS
Only for files stored in linux
 

JasKinasis

Well-Known Member
Joined
Apr 25, 2017
Messages
1,317
Reaction score
1,867
Credits
8,257
Find command is very useful option here. You can search for files older then 1 month and delete them with -delete option.
$ find /tmp -mtime +7 -type f -name '*.tmp' -delete
A very good suggestion, but the example you have posted finds and deletes files that were modified more than 7 days ago.

For the OP to find and delete backup files that were modified over a month ago they would need to use +30 for the -mtime option.
 
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Members online


Top