Sometimes it can be very useful to create cpmove archives (backups) for all the accounts owned by a reseller. There is no way to do this via WHM. We will show a method here by using the cPanel pkgacct script and the WHM API listaccts function.
For more information visit The pkgacct Script documentation ; WHM API 1 Functions – listaccts
Below is the command to backup all accounts owned by reseller_username (replace reseller_username with your reseller username and specify the output directory):
# for i in $(whmapi1 listaccts searchtype=owner search=reseller_username want=user | grep user: | awk '{print $2}'); do /scripts/pkgacct $i /backup/choose_directory; done
The output directory MUST exist. Otherwise, the backups will be created in /home directory. The backups will be created as cpmove-_.tar.gz files.
———————————————–
An example – reseller account max – it has one owned cPanel account – max1:
root@sweb [~]# for i in $(whmapi1 listaccts searchtype=owner search=max want=user | grep user: | awk '{print $2}'); do /scripts/pkgacct $i /backup/max; done
[2018-04-05 11:39:20 -0500] pkgacct started.
[2018-04-05 11:39:20 -0500] pkgacct version 10 - user : max1 - tarball: 1 - target mysql : default - split: 0 - incremental: 0 - homedir: 1 - mailman: 1 - backup: 0 - archive version: 4 - running with uid 0
[2018-04-05 11:39:20 -0500] pkgacct using '/usr/local/cpanel/3rdparty/bin/pigz -6 --processes 1 --blocksize 128 --rsyncable' to compress archives
[2018-04-05 11:39:20 -0500] pkgacct working dir : /backup/max/cpmove-max1
[2018-04-05 11:39:20 -0500] Copying Reseller Config...[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:20 -0500] Copying Suspension Info (if needed)...[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:20 -0500] Copying installed SSL certificates and keys...[2018-04-05 11:39:20 -0500] Performing “ApacheTLS” component....
[2018-04-05 11:39:20 -0500] Completed “ApacheTLS” component.
[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:20 -0500] Storing SSL domain......[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:20 -0500] Copying Domain Keys....[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:20 -0500] Copying Counter Data....[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:20 -0500] Copying Bandwidth Data....[2018-04-05 11:39:20 -0500] Performing “Bandwidth” component....
Summary databases … done!
[2018-04-05 11:39:20 -0500] Completed “Bandwidth” component.
[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:20 -0500] Copying Dns Zones.......max1.com...[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:20 -0500] Copying Mail files....[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:20 -0500] Copying proftpd file....[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:20 -0500] Copying www logs.......log file sizes [0 byte(s)]......max1.com...[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:20 -0500] Copy userdata...[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:20 -0500] Copy custom virtualhost templates...[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:20 -0500] Copying mailman lists and archives....[2018-04-05 11:39:20 -0500] Done copying mailman lists and archives.
[2018-04-05 11:39:20 -0500] Copying homedir.............
[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:20 -0500] Fixing up EA4 .htaccess blocks: Done.
[2018-04-05 11:39:20 -0500] Performing “Postgresql” component....
[2018-04-05 11:39:20 -0500] Completed “Postgresql” component.
[2018-04-05 11:39:20 -0500] Performing “Mysql” component....
[2018-04-05 11:39:20 -0500] Determining mysql dbs...[2018-04-05 11:39:20 -0500] ...mysqldump version: 10.1.32...[2018-04-05 11:39:20 -0500] ...mysql version: 10.1...[2018-04-05 11:39:20 -0500] Saving mysql privs...[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:20 -0500] ...Done
[2018-04-05 11:39:20 -0500] Storing mysql dbs...[2018-04-05 11:39:20 -0500] ...Done
[2018-04-05 11:39:20 -0500] Completed “Mysql” component.
[2018-04-05 11:39:20 -0500] Copying cpuser file.......[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:20 -0500] Copying crontab file.......[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:20 -0500] Performing “Quota” component....
[2018-04-05 11:39:20 -0500] Completed “Quota” component.
[2018-04-05 11:39:20 -0500] Performing “Integration” component....
[2018-04-05 11:39:20 -0500] Completed “Integration” component.
[2018-04-05 11:39:20 -0500] Performing “AuthnLinks” component....
[2018-04-05 11:39:20 -0500] Completed “AuthnLinks” component.
[2018-04-05 11:39:20 -0500] Performing “APITokens” component....
[2018-04-05 11:39:20 -0500] Completed “APITokens” component.
[2018-04-05 11:39:20 -0500] Performing “AutoSSL” component....
[2018-04-05 11:39:20 -0500] Completed “AutoSSL” component.
[2018-04-05 11:39:20 -0500] Storing Subdomains....
[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:20 -0500] Storing Parked Domains....
[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:20 -0500] Storing Addon Domains....
[2018-04-05 11:39:20 -0500] Copying password.......[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:20 -0500] Copying shell.......[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:20 -0500] Performing “PublicContact” component....
[2018-04-05 11:39:20 -0500] Completed “PublicContact” component.
[2018-04-05 11:39:20 -0500] Creating Archive ....[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:20 -0500] pkgacctfile is: /backup/max/cpmove-max1.tar.gz
[2018-04-05 11:39:20 -0500] md5sum is: 14b564a6740f515a05573d1678a0a0b8
[2018-04-05 11:39:20 -0500]
[2018-04-05 11:39:20 -0500] size is: 63125
[2018-04-05 11:39:20 -0500]
[2018-04-05 11:39:20 -0500] homesize is: 167936
[2018-04-05 11:39:20 -0500]
[2018-04-05 11:39:20 -0500] homefiles is: 54
[2018-04-05 11:39:20 -0500] pkgacct completed
[2018-04-05 11:39:20 -0500] pkgacct started.
[2018-04-05 11:39:20 -0500] pkgacct version 10 - user : max - tarball: 1 - target mysql : default - split: 0 - incremental: 0 - homedir: 1 - mailman: 1 - backup: 0 - archive version: 4 - running with uid 0
[2018-04-05 11:39:20 -0500] pkgacct using '/usr/local/cpanel/3rdparty/bin/pigz -6 --processes 1 --blocksize 128 --rsyncable' to compress archives
[2018-04-05 11:39:20 -0500] pkgacct working dir : /backup/max/cpmove-max
[2018-04-05 11:39:20 -0500] Copying Reseller Config...[2018-04-05 11:39:20 -0500]
[2018-04-05 11:39:20 -0500] Copying Reseller Packages and Features ...
[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:20 -0500] Copying Suspension Info (if needed)...[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:20 -0500] Copying installed SSL certificates and keys...[2018-04-05 11:39:20 -0500] Performing “ApacheTLS” component....
[2018-04-05 11:39:20 -0500] Completed “ApacheTLS” component.
[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:20 -0500] Storing SSL domain......[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:20 -0500] Copying Domain Keys....[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:20 -0500] Copying Counter Data....[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:20 -0500] Copying Bandwidth Data....[2018-04-05 11:39:20 -0500] Performing “Bandwidth” component....
Summary databases … done!
[2018-04-05 11:39:20 -0500] Completed “Bandwidth” component.
[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:20 -0500] Copying Dns Zones.......max.com...[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:20 -0500] Copying Mail files....[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:20 -0500] Copying proftpd file....[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:20 -0500] Copying www logs.......log file sizes [0 byte(s)]......max.com...[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:20 -0500] Copy userdata...[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:20 -0500] Copy custom virtualhost templates...[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:20 -0500] Copying mailman lists and archives....[2018-04-05 11:39:20 -0500] Done copying mailman lists and archives.
[2018-04-05 11:39:20 -0500] Copying homedir.............
[2018-04-05 11:39:20 -0500] Done
[2018-04-05 11:39:21 -0500] Fixing up EA4 .htaccess blocks: Done.
[2018-04-05 11:39:21 -0500] Performing “Postgresql” component....
[2018-04-05 11:39:21 -0500] Completed “Postgresql” component.
[2018-04-05 11:39:21 -0500] Performing “Mysql” component....
[2018-04-05 11:39:21 -0500] Determining mysql dbs...[2018-04-05 11:39:21 -0500] ...mysqldump version: 10.1.32...[2018-04-05 11:39:21 -0500] ...mysql version: 10.1...[2018-04-05 11:39:21 -0500] Saving mysql privs...[2018-04-05 11:39:21 -0500] Done
[2018-04-05 11:39:21 -0500] ...Done
[2018-04-05 11:39:21 -0500] Storing mysql dbs...[2018-04-05 11:39:21 -0500] ...Done
[2018-04-05 11:39:21 -0500] Completed “Mysql” component.
[2018-04-05 11:39:21 -0500] Copying cpuser file.......[2018-04-05 11:39:21 -0500] Done
[2018-04-05 11:39:21 -0500] Copying crontab file.......[2018-04-05 11:39:21 -0500] Done
[2018-04-05 11:39:21 -0500] Performing “Quota” component....
[2018-04-05 11:39:21 -0500] Completed “Quota” component.
[2018-04-05 11:39:21 -0500] Performing “Integration” component....
[2018-04-05 11:39:21 -0500] Completed “Integration” component.
[2018-04-05 11:39:21 -0500] Performing “AuthnLinks” component....
[2018-04-05 11:39:21 -0500] Completed “AuthnLinks” component.
[2018-04-05 11:39:21 -0500] Performing “APITokens” component....
[2018-04-05 11:39:21 -0500] Completed “APITokens” component.
[2018-04-05 11:39:21 -0500] Performing “AutoSSL” component....
[2018-04-05 11:39:21 -0500] Completed “AutoSSL” component.
[2018-04-05 11:39:21 -0500] Storing Subdomains....
[2018-04-05 11:39:21 -0500] Done
[2018-04-05 11:39:21 -0500] Storing Parked Domains....
[2018-04-05 11:39:21 -0500] Done
[2018-04-05 11:39:21 -0500] Storing Addon Domains....
[2018-04-05 11:39:21 -0500] Copying password.......[2018-04-05 11:39:21 -0500] Done
[2018-04-05 11:39:21 -0500] Copying shell.......[2018-04-05 11:39:21 -0500] Done
[2018-04-05 11:39:21 -0500] Performing “PublicContact” component....
[2018-04-05 11:39:21 -0500] Completed “PublicContact” component.
[2018-04-05 11:39:21 -0500] Creating Archive ....[2018-04-05 11:39:21 -0500] Done
[2018-04-05 11:39:21 -0500] pkgacctfile is: /backup/max/cpmove-max.tar.gz
[2018-04-05 11:39:21 -0500] md5sum is: 6165782f02dffdfdb62892a5e4669f27
[2018-04-05 11:39:21 -0500]
[2018-04-05 11:39:21 -0500] size is: 63383
[2018-04-05 11:39:21 -0500]
[2018-04-05 11:39:21 -0500] homesize is: 1949696
[2018-04-05 11:39:21 -0500]
[2018-04-05 11:39:21 -0500] homefiles is: 58
[2018-04-05 11:39:21 -0500] pkgacct completed
root@web [~]# ls /backup/max
./ ../ cpmove-max.tar.gz cpmove-max1.tar.gz
root@web [~]#