# Migrate application
Migrating an application is to move the application data to a new location and then configure it to ensure access after the move.
Migration is an operation that needs to be treated with caution. Before migration, you need to clearly understand the following points:
- Moved application data objects: website source files or database data files
- Destination location: transfer between server directories (local) or external server (external)
The combination of the migrated object and the destination location forms a variety of migration scenarios. The most common migration scenarios are detailed below:
# Migrate source code locally
Assume the folder name of your application is mysite1 in the directory /data/wwwroot, then you may migrate mysite1 to the directory /data2/wwwroot, let us define it this way:
- original folder: /data/wwwroot/mysite1
- destination folder: /data2/wwwroot/mysite1
- Use WinSCP to connect your Instance
- Copy the original folder mysite1 to the destination directory: /data2/wwwroot
- Modify the DocumentRoot, Directory items in the VirtualHost segment of vhost.conf
- Save vhost.conf, and restart service
# Restart Apache service systemctl restart httpd
- Test the migration, then delete the original folder
# Migrate Database files locally
There is no special case, we do not recommend migrating database files to another directory on the Server. After all, major cloud platform's disks can be expanded.
# Migrate /data to Data Disk
The /data folder is on the system disk by default. When you need to transfer to the data disk, the steps are as follows:
- Before you start the migration, please be sure to make a data backup
- Prepare your data disk and attach it to your Cloud Server
- Initialize the data disk
- Create a temp folder on your Server, e.g.
- Mount data disk to the folder /temp
- Stop Apache and MySQL services
systemctl stop httpd mysqld
- Copy all files under /data to /temp
If the data is large, the cut or copy may fail
- After the data transfer is completed, umount your data disk from /temp and Mount it to /data again
- Start Apache and MySQL
systemctl start httpd mysqld
- Test it
Initialize the data disk means you partition and format data disk, these operation are very complex, please refer to chapter of documentation Using Cloud Server (opens new window)
# Migrate to another Instance
The migration of applications from one server (original Server) to another (destination Server) is a complex plan. The basic steps are as follows:
- Deploy LAMP on the destination Server.
- Download the application's source code from original Server to the local computer through WinSCP, and then upload them to destination Server.
- Export the database from the original Server via phpMyAdmin and then import them to destination server.
- Copy the contents of the vhost.conf from the original Server to the vhost.conf of destination server .
- Save it, tehn restart the Apache service.
- Resolve the domain to destination Server and wait for the domain resolution to take effect.
- Test the availability by visiting the application through your domain name.
- Publish the it.
If there are multiple applications on a Server that need to be migrated, it is recommended to migrate amd test one by one.