Does anyone know of an automated script that will check all cpanel accounts disk usage and remove them from the server wide cpanel backup if the disk usage is higher than X amount.
Thanks
Does anyone know of an automated script that will check all cpanel accounts disk usage and remove them from the server wide cpanel backup if the disk usage is higher than X amount.
Thanks
You can use find to purge backups over a certain size:
The above command will search through /backups for files that are over 10GB in size and remove them. Adjust the /backups to the correct path of your backups and the +10485760k to fit your needs. This can be scheduled to run via Cron.Code:find /backups -type f -size +10485760k -exec rm -f {} \;
Not quite what I was looking for. I am looking for a script to remove large accounts from the cpanel backup list so they are not backed up nightly.
Its under WHM --> Configure backup --> Select Specific Users
That list.
Hi,
Here's a script. Configure this in cron to run weekly for example (@weekly /root/script.sh)
Enjoy!Code:#!/bin/bash max_size="4096" # This is 4096KB or 4MB ls -1 /var/cpanel/users/| \ while read u; do size=$(repquota -a | grep ${u}|awk '{print $3}'|sort -k 1 -nr|head -1); if [ "${size}" -ge "${max_size}" ]; then echo "${u}" >> /tmp/cpbackup-userskip.conf; fi; done; sort -u /tmp/cpbackup-userskip.conf /etc/cpbackup-userskip.conf > /tmp/cpbackup-userskip.conf.uniq; cp -f /tmp/cpbackup-userskip.conf.uniq /etc/cpbackup-userskip.conf; rm -f /tmp/cpbackup-userskip.conf.*;
Joe / UNIXY
- Truly Fully Managed Servers http://unixy.net/
- Fastlayer.com: Varnish for the cloud.
- cPanel Varnish Plugin
That script didn't work. Any other ones?
Here's a revised code based on UNIXy :
Code:#!/bin/bash max_size="2097152" # This is 2097152KB or 2GB for u in `ls /var/cpanel/users/`; do size=$(repquota -a | grep ${u}|awk '{print $3}'|sort -k 1 -nr|head -1); if [ "${size}" -ge "${max_size}" ]; then echo "${u}" >> /tmp/cpbackup-userskip.conf; fi; done; sort -u /tmp/cpbackup-userskip.conf /etc/cpbackup-userskip.conf > /tmp/cpbackup-userskip.conf.uniq; cp -f /tmp/cpbackup-userskip.conf.uniq /etc/cpbackup-userskip.conf; rm -f /tmp/cpbackup-userskip.conf.*;
Sorry, I'm pretty new at all of this stuff.
Can you explian to me how I would use this?