cPanel Account copy: Package over quota

Many hosting providers use PHP built as an Apache module, so that when a hosting customer uploads files through a script, they are owned by the user “nobody”. This causes a major problem with quotas, since cPanel will only count files that are owned by the user. Files owned by nobody are not counted toward quotas. If a user installs an uploader script, then the user can extend their actual disk usage far beyond their quota.

This can be a problem when moving accounts from one server to another, if the account package is larger than the allowed quota, cPanel will not restore all the files to the new server. This usually results in accounts being restored but with incomplete file sets. Even worse, cPanel will report that the account was restored successfully:

/bin/gtar: ./.fantasticodata/PerlDesk: Cannot mkdir: No such file or directory
/bin/gtar: ./.contactemail: Cannot write: Disk quota exceeded
/bin/gtar: ./fantastico_backups/blog.backup.1137314599.tgz: Cannot open: No such file or directory
/bin/gtar: Error exit delayed from previous errors

Account Restore Complete
Unlocking password for user,
passwd: Success.
checked 107 files….

The simple workaround is to increase the customer's quota in WHM before packaging the account. This way, the account has a large enough quota to restore all the files.

If the account is already packaged and access to the origin server is no longer available, then the only option is to edit the quota file stored in the cPanel package. This will allow the new server to restore the file with a larger quota limit, thus ensuring all files are restored. The following real-world example shows the backup package is copied to the destination server in the /home directory, ready to be restored. In addition, there are approx 1.5GB of files in the account, but the quota is set to 700MB.

root@server [/home]# gunzip USER.tar.gz
root@server [/home]# tar -f USER.tar -x USER/quota
root@server [/home]# cat USER/quota
root@server [/home]# echo 2000 > USER/quota
root@server [/home]# tar -rf USER.tar USER/quota
root@server [/home]# rm -rf USER/
root@server [/home]# gzip USER.tar
root@server [/home]# /scripts/restorepkg USER

Of course, you can solve this issue in advance by enabling PHP to run under suPHP or FastCGI, so that scripts will create files owned by the cPanel user, rather than nobody. Then, the user will be alerted when they hit quota.