Migrating sites between DirectAdmin servers

These are some basic notes for reference just in case I need to do the migration thing again!!!

Steps taken on the old server

  1. Created a new reseller account.

  2. Created sites in the new reseller account as domain.com2 for the domains that needed to be migrated. DA won't let you add the same name twice, which is why I used a different one for the time being. Doing this will setup all the required files/paths needed to use the website.

  3. Copied the files to the new domain.
    # cp -pR /home/olduser/domains/domain.com/* /home/newuser/domains/domain.com2/
    # chown -R newuser:newuser /home/newuser/domains/domain.com2
  4. Did a search for the old file path and updated it to the new file path.
    # for x in `find /home/newuser/domains/*/public_html -type f -print0 | xargs --null grep -l /home/olduser`; do perl -pi.bak -e 's/\/home\/olduser/\/home\/newuser/g' $x ; done
  5. Swapped around the the email folders.
    # cd /etc/virtual
    # mv domain.com domain.com.tmp
    # mv domain.com2 domain.com
    # mv domain.com.tmp domain.com2
  6. Copied over the imap files. Any data in /home/olduser/imap needed to be copied over. There will also be permission issues as well, but can be fixed afterwards with the set_permissions.sh script.

  7. Changed user for the imap files.
    # find /home/newuser/imap -user olduser | xargs chown newuser:newuser
  8. Renamed the existing domains with a suffix of ".old".

  9. Renamed the new domains to domain.com from domain.com2.

  10. Logged in as reseller and created a backup.

  11. Created a script and dumped out single databases.
    #!/bin/bash
    # dbExport.sh

    OLD_DB=(
    db1
    db2
    db3
    ...
    )

    for ((i=0; i<${#OLD_DB[@]}; i++))
    do
      mysqldump --opt -u root --password={psswd} ${OLD_DB[$i]} > ./db/${OLD_DB[$i]}.db
    done
  12. Did a search and created a list of folders with 777 permission set.
    # find /home/newuser/domains -perm 0777 -type d > 777.txt
  13. Setup dns for each domain with a www1 A record to point to the new server IP. Better solution, would be to edit the local hosts file for testing purpose.

Steps taken on the new server

  1. Created the reseller to receive the restore.

  2. Copied over the archive to the /home/newuser/user_backups folder.

  3. Logged in as Reseller and deleted the default domain that was created for the reseller.

  4. Renamed the existing domains created earlier with a .del suffix.

  5. Restored the sites from the backup.

  6. Created the required databases via the user interface to receive the dumps.

  7. Imported the databases from the dumps via script.
    #!/bin/bash
    # dbImport.sh

    OLD_DB=(
    db1
    db2
    db3
    ...
    )

    NEW_DB=(
    prefix_db1
    prefix_db2
    prefix_db3
    ...
    )

    for ((i=0; i<${#OLD_DB[@]}; i++))
    do
      mysql -u root --password={passwd} ${NEW_DB[$i]} < ./db/${OLD_DB[$i]}.db
    done
  8. Did a search for the old database password that was used and updated all of the config files to use the new database.
    # for x in `find /home/newuser/domains/*/public_html -type f -print0 | xargs --null grep -l oldDbPasswd`; do vi $x ; done
  9. Changed owner of folder recursively to apache for all files needing 777 permission.
    # for x in `cat 777.txt` ; do chown -R apache $x ; done
  10. Added www1 ServerAlias to each domain for testing.
    Admin Level -> Custom Httpd configurations -> domain.com
    In the top text area, added this *one* line:
    ServerAlias www1.|DOMAIN|

References:

  1. Moving Domains between Users
  2. Custom httpd.conf
  3. Wildcard *.domain.com setup

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
lower DNS TTL for all DirectAdmin domains

cd /usr/local/directadmin/data/templates
perl -pi.bak -e 's/14400/300/' named.db
echo "action=rewrite&value=named" >> /usr/local/directadmin/data/task.queue

Check "/var/named/*.db" to verify once the queued task is complete.

Reference: http://help.directadmin.com/item.php?id=87

Comment