How to move a domain to a dedicated/another account in DirectAdmin

DirectAdmin comes with a script that allows you to move a domain between accounts. (on cPanel this can be considered moving an addon domain to another account). The script is located at /usr/local/directadmin/scripts/move_domain.sh and the command for using it is:

/usr/local/directadmin/scripts/move_domain.sh <domain> <olduser> <newuser>
#!/bin/sh
# This script is written by Martynas Bendorius and DirectAdmin
# It is used to move domain from one user to another
# Official DirectAdmin webpage: http://www.directadmin.com
# Usage:
# ./move_domain.sh <domain> <olduser> <newuser>

VERSION=0.3
......................

Example for moving domain ph-test.com from plothost16 account to the plothost17 account:

[root@web ~]# /usr/local/directadmin/scripts/move_domain.sh ph-test.com plothost16 plothost17
Moving domain data to the plothost17 user.
Setting ownership for ph-test.com domain.
Removing domain from plothost16 user.
Adding domain to plothost17 user.
Changing domain owner.
Debug mode. Level 10

2022/01/11 14:06:28  info starting queues
dataskq: command: action=cache&value=showallusers
dataskq: command: action=rewrite&value=httpd
Error retrying plothost17:ph-test.com: Unable to get a lock for plothost17: ph-test.com<br>

Error retrying plothost17:plothost17.com: Unable to get a lock for plothost17: plothost17.com<br>

Updating email settings.
cat: /usr/local/directadmin/data/users/plothost17/domains/ph-test.com.pointers: No such file or directory
cat: /usr/local/directadmin/data/users/plothost17/domains/ph-test.com.pointers: No such file or directory
Updating ftp settings.
Can't open /home/plothost17/domains/ph-test.com/awstats/.data/*.conf: No such file or directory.
Can't open /home/plothost17/domains/ph-test.com/awstats/awstats.pl: No such file or directory.
Can't open /home/plothost17/domains/ph-test.com/awstats/*/.data/*.conf: No such file or directory.
Can't open /home/plothost17/domains/ph-test.com/awstats/*/awstats.pl: No such file or directory.
Domain has been moved to plothost17 user.
[root@web ~]#

Notice that the script will copy ALL databases from the old account to the new account. You should manually check which databases the site in question is using and remove the unneeded ones.


Another way in which you can move a domain between accounts:

1. Create a backup only for the selected domain on the old account (See How to backup specific domains in DirectAdmin)

2. Go to Domain Setup and remove the domain

3. Copy the archive to the new account – /home/newuser/backups/ . Be sure to change file permissions.

4. Log into the new account and restore the backup.

Notice that the script will copy ALL databases from the old account to the new account. You should manually check which databases the site in question is using and remove the unneeded ones. Also, this operation will change the databases prefix, so you should update the configuration settings for the site. Try the operation first on a test account.


How to move a domain from an account to a dedicated account (as an admin):

1. Create a backup only for the selected domain on the old account (See How to backup specific domains in DirectAdmin)

2. Go to Domain Setup and remove the domain

3. Copy the archive to the admin account – /home/admin/admin_backups/ . Rename the file from backup-Jan-12-2022-1.tar.gz for example, to user.admin.NEWUSERNAME.tar.gz , where NEWUSERNAME is the username you want for the new account.

4. Log into your admin account and restore the archive. A new account will be created and it will have only the domain name which you backed up at step1.

Notice that the script will copy ALL databases from the old account to the new account. You should manually check which databases the site in question is using and remove the unneeded ones. Also, this operation will change the databases prefix, so you should update the configuration settings for the site. Try the operation first on a test account.

Leave a Reply