Este artigo descreve como transferir contas cPanel entre servidores, é preciso ter acesso a shell e ser usuário root nos dois servidores, você vai fazer o backup de todos arquivos, incluindo a senha, banco dados, e-mails, estatisticas e tudo que pertence ao usuário cPanel.
Para a realização do backup das contas do cPanel utilizaremos somente os scripts nativos do cPanel, SSH e SCP. Para quem não conhece, SCP ou Secure Copy é um meio seguro para transferência de arquivos entre servidores, muito conhecido entre os heavy users de Linux.
Antes de iniciar, vamos considerar que temos dois servidores:
Servidor A
Estão as contas dos usuários do cPanel.
IP: 192.168.0.1
Servidor B
Receberá as contas do cPanel do Servidor A.
IP: 172.16.0.1
Criar o Backup de todas as contas
Para criar o backup, execute o comando:
cat /var/cpanel/users | while read a; do
/scripts/pkgacct $a
done
Se quiser criar o backup de apenas uma conta, execute somente o comando :
/scripts/pkgacct cPanelUser
Para cada conta será criado um arquivo chamado cpmove-nomedaconta.tar.gz , os arquivos serão alocados automaticamente dentro do diretório /home.
Transferir para o novo servidor
Após criados os arquivos de backup precisamos transferir para o Servidor B, vamos utilizar o SPC para a transferência.
scp cpmove-* root@172.16.0.1:/home
O comando acima vai transferir todos os arquivos de backup para dentro do diretório /home do Servidor B.
Se você tiver feito o backup de todas as contas precisa enviar também o arquivo /var/cpanel/users, dentro deste arquivo contém o nome de todos os usuários do cPanel. Precizamos enviar para dentro do diretório /home no Servidor B com o nome de users.txt .
scp /var/cpanel/users root@172.120.0.1:/home/users.txt
Restaurar contas
Chegou o momento mais esperado e mágico, restaurar todas as contas no cPanel. Execute o comando:
cat /home/user/txt | while read a; do
/scripts/restorepkg $a
done
Pronto, a sua lista de contas do Servidor A estão replicadas no Servidor B.
http://www.s2move.com/backup-contas-cpanel-pela-shell/
https://documentation.cpanel.net/pages/viewpage.action?pageId=4522338
For cPanel & WHM 11.40
Overview
You can use the pkgacct
script to create a cpmove
archive for a specified account. After you have created the cpmove
archive, you can transfer the account between servers.
Call the script
To call this script, log in to your server via SSH as the root
user and execute the following script:
1
|
/scripts/pkgacct $user |
Important:
In the example above $user
stands for the username that corresponds to the cPanel account you wish to package.
After you issue this command, the pkgacct
script will begin to create the cpmove
archive from the account $user
.
Notes:
- The account’s username is the only required parameter, unless the
--bincheck
argument is used. - If you wish to specify any arguments, pass those arguments before
$user
. Most of the arguments you can use with this script are unordered. However, if you wish to use--allow-override
, you must pass it first (in the0th
position). You must always pass the$user
and$destination
variables last. Whenever the$destination
variable is used, you must pass it in last place, after$user
. For example:1/scripts/pkgacct
--allow-override --skiphomedir --skipacctdb $user $destination
In the example above
$user
stands for the username that corresponds to the cPanel account you wish to package.$destination
stands for the directory in which you wish to store thecpmove
archive.
Available arguments
The pkgacct
script can accept the following arguments.
Parameter
|
Description
|
Input Type
|
---|---|---|
$user | This variable is required whenever --bincheck is not used. When passing this variable, replace $user with the username that corresponds to the cPanel account you wish to package. |
string |
$destination | This is an optional variable that allows you to specify the path to the directory in which you wish to store the cpmove archive. The$destination variable must follow the $user variable, e.g. /scripts/pkgacct $user $destination . |
string |
–allow-override | Causes the script to use instructions in /var/cpanel/lib/Whostmgr/Pkgacct/pkgacct , if any are present. |
N/A |
–bincheck | This parameter ensures that any scripts called by the cPanel binary will run. If successful, the script will print 'BinCheck ok' . When you use this argument, you do not need to pass $user . |
N/A |
–version | The version of the archive being created. | string (See below for usage instructions.) |
–mysql | The version of MySQL used by the account’s databases. | string (See below for usage instructions.) |
–use_backups | Causes the most recent backup to be converted into a cpmove archive. This option will speed up the process but may result in lost or old data. |
N/A |
–skiphomedir | This parameter will exclude the user’s home directory from the archive. If the account will be transferred, the user’s home directory can be moved with a faster protocol. | N/A |
–incremental | When this parameter is used, only information that was not contained within the previous archive will be packaged. This parameter will not work if no cpmove archive is found. |
N/A |
–split | Causes the archive to be created in chunks. This will reduce the overall load on the system. | N/A |
–nocompress | Passing this parameter will leave the resulting cpmove archive uncompressed. |
N/A |
–compress | This parameter can override the --nocompress argument if it is present. There is no reason to use this argument as archives are compressed by default. |
N/A |
–skipacctdb | This parameter prevents the account’s databases from being included in the archive. | N/A |
–userbackup | Allows the user to use the resulting cpmove archive as a backup for the account. |
N/A |
–backup | Causes the resulting archive to be used as an account’s backup. | N/A |
How to use the –version and –mysql arguments
To use pkgacct
‘s --version
and --mysql
arguments, you will need to enter a space between the argument and the value you wish to pass to it. For example:
/scripts/pkgacct --version 2 --mysql 5.5 . 11 $user |
Note:
This information only applies to the --version
and --mysql
arguments. Pass the $user
and $destination
parameters to the script last.
Remember:
In the example above $user
stands for the username that corresponds to the cPanel account you wish to package. $destination
stands for the directory in which you wish to store the cpmove
archive.