Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 8316
  • Last Modified:

cPanel/WHM: How can I delete old backups?

Hi,

My /backup drive is 100% full. When I'm terminating cPanel accounts they are not being removed from the backup.

How can I delete the accounts that has been terminated more than X days ago?

Thanks.
0
everactive
Asked:
everactive
  • 3
  • 3
1 Solution
 
SteveIT ManagerCommented:
0
 
everactiveAuthor Commented:
Hi,

The link you mentioned doesn't contain the solution.
0
 
shaunakCommented:
cpanel stores the backups in /backup/cpbackup location

There you would find three types of backups:-
daily/
monthly/
weekly/

You can check the backups' date and delete the tar.gz file accordingly.


0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
everactiveAuthor Commented:
shaunak,

That is not feasible in my case, there are hundreds of accounts.
0
 
shaunakCommented:
Dont delete those 3 folders.
Go to monthly folder and then give
ll -S -t
this will give you list in date wise sorted manner. Then I think you can delete certain old backups of the domains which are currently not there.
There you will find certain backups of domains that may not be currently active on your server. Ideally you should find monthly backups not more than 2 months old, but if there are some which are more than 2 month old then these backups are those of the terminated accounts.


0
 
everactiveAuthor Commented:
Hi,

When terminating a cPanel account the back stays forever until manually deleted. That's the problem.

So what I need here is a code to delete the folder that has not been modified for x days.
0
 
shaunakCommented:
The below code will delete all .tar.gz files which are older than 240 days.
find /backup/cpbackup/ -mtime +240 -name "*tar.gz" -exec rm {} \;

If you are doing any modifications in the above code then make sure that before executing the delete command you do a dry run with ls command and get the desired find results
find /backup/cpbackup/ -mtime +240 -name "*tar.gz" -exec ls {} \;

-exec passes the search results to the succeeding command.
Place the code in a .sh or just a text file and make it executable by
chmod 644 file_name.txt
Now set a cron to execute this file every 3 months or so.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now