?
Solved

cPanel/WHM: How can I delete old backups?

Posted on 2010-01-10
7
Medium Priority
?
7,429 Views
Last Modified: 2013-12-16
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
Comment
Question by:everactive
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 17

Expert Comment

by:Steve
ID: 26283039
0
 

Author Comment

by:everactive
ID: 26288502
Hi,

The link you mentioned doesn't contain the solution.
0
 
LVL 8

Expert Comment

by:shaunak
ID: 26297296
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
WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

 

Author Comment

by:everactive
ID: 26310414
shaunak,

That is not feasible in my case, there are hundreds of accounts.
0
 
LVL 8

Expert Comment

by:shaunak
ID: 26316890
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
 

Author Comment

by:everactive
ID: 26327808
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
 
LVL 8

Accepted Solution

by:
shaunak earned 2000 total points
ID: 26329611
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

Independent Software Vendors: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to demonstrate how we can use conditional statements using Python.
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses
Course of the Month14 days, 12 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question