Our hosted server recently ran out of disk space – an awkward situation. A little research revealed that /var/lib contained quite a lot of data – about 33GB more than we were expecting, most of it in /var/lib/psa/dumps/tmp.
Turns out that this is where Plesk puts its temporary files when doing backups, and for some reason they weren’t getting removed, and in our case, they totalled 33GB. So… first of all we removed them, and then set about making sure the situation didn’t happen again.
Chris Meller notes that sometimes the permissions on the directory get broken (such as when you restore from a backup), so I made sure that it was owner/group psaadm:psaadm and then, just to be sure, added a quick nightly cron job for root that runs the following script to remove any temporary files older than 90 days. Job done.
# Delete backup more than 90 days old.
echo "Checking for files older than $daysToKeep days in $backupDir"
listOfFiles=`find $backupDir -mtime +$daysToKeep`
if [ ! -z $listOfFiles ]
echo "Found [$listOfFiles]"
echo "None found."
for toDelete in $listOfFiles
echo "Deleting $toDelete"
rm -rf $toDelete