Web Hosting Talk







View Full Version : Limit size of cPanel Backup


Sandino
03-18-2010, 05:35 PM
Does anyone know of a method and or script to limit the size of cpanel backups?
Say, if the account is larger than X GB, then it will not backup the account?

I know that you can specify specific users if you want, but that would just be a hassle if there are many accounts.

I have tried googleing a bit, and haven't found a straight answer.

So if you could help, it would be appreciated greatly :)

activelobby4u
03-22-2010, 10:45 AM
You could simply write a custom bash script

Program flow would be

1. check the size of the account using quota
2. see if it exceeds the threshold value
3. start backup process if low.

:agree:

gozargah
09-12-2010, 10:35 AM
Any other idea?

sirdopes
09-14-2010, 07:54 PM
You would either need to write a bash script or modify the backup script to check the account size. Another option would be to use a 3rd party plugin for backing up the accounts and disable the built in one in cpanel.

REMX
09-14-2010, 08:16 PM
#!/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*;



Source: http://forums.cpanel.net/f49/backup-configuration-accounts-less-than-2gb-164910.html

gozargah
09-15-2010, 09:44 AM
Thank you, i run this script as cronjob.
But i have following error, when cronjob run:

/root/backuplimit.sh: line 7: repquota: command not found
/root/backuplimit.sh: line 8: [: : integer expression expected
sort: open failed: /tmp/cpbackup-userskip.conf: No such file or directory

Dave - Just199
09-15-2010, 09:45 AM
touch /tmp/cpbackup-userskip.conf