pkgacct is a command-line tool in cPanel/WHM used for creating backups of cPanel accounts. It is part of cPanel's internal utilities and is often used by system administrators to package (archive) a cPanel account, including all its files, databases, emails, and configurations.
The tool generates a backup file in .tar.gz format, which can be restored on the same or another server using the restorepkg utility.
1. Create a Backup for a cPanel Account:
This will create a backup of the cPanel account username in the default backup directory (/home).
2. Create a Backup in a Custom Directory:
This will save the backup in the specified /backup/ directory.
.tar.gz archive. You can control this behavior with the --nocompress or --compress options.
pkgacct offers several options to customize the backup process. Here are the most commonly used flags:
| Option | Description |
|---|---|
--skiphomedir |
Skips the home directory files in the backup. Useful for large accounts where you only need to migrate settings. |
--skipdns |
Skips DNS zone files from the backup. |
--compress |
Ensures the backup is compressed (this is enabled by default). |
--split |
Splits the archive into multiple parts (useful for large backups or transfer limits). |
--nocompress |
Creates an uncompressed .tar archive. Can be faster for local transfers or when disk I/O is a bottleneck. |
--incremental |
Creates an incremental backup instead of a full backup (requires a previous full backup). |
--skiplogs |
Skips log files (like access_log, error_log) in the backup to save space. |
--skipsymlinks |
Skips symbolic links in the home directory. |
Use the restorepkg utility to restore a backup created with pkgacct.
This will restore the cPanel account from the backup file. The username will be the same as in the original backup.
/usr/local/cpanel/scripts/restorepkg --force <backup_file> <new_username>. Use the --force flag with caution.
cpmove-username.tar.gz file to the destination server (via SCP, FTP, or rsync), and use restorepkg to complete the migration.scp or rsync over SSH. Set proper permissions on backup directories (e.g., chmod 600).--skiphomedir or --skipdns to exclude data that isn't required for your specific use case, reducing backup size and time.--skiphomedir flag to exclude home directory files if storage is limited. Also, check for available inodes (df -i).--nocompress option to speed up backup creation (compression is CPU-intensive). You can compress it later with gzip if needed./home/ as cpmove-<username>.tar.gz. Use ls -la /home/cpmove* to list backups.ls -la /var/cpanel/users/.With this guide, you can effectively use pkgacct for cPanel account backups, migrations, and disaster recovery planning.