Migrate Bind Mount to AWS EFS
Migrating your existing Appsmith installation on an AWS ECS from Bind Mount to Amazon Elastic File System (EFS) can enhance flexibility and scalability. This page outlines steps for migrating your AWS ECS on EC2 Appsmith installation from Bind Mount to AWS EFS using the AWS Management Console.
System requirements
- At least 2 GB of free storage space for backup and update tasks.
Prerequisites:
- A self-hosted Appsmith instance installed on an AWS ECS cluster (running on an EC2 instance), using a Bind Mount volume.
- Create a backup of the Appsmith instance, see Backup instance guide.
- You will not be able to use the built-in MongoDB with EFS as it will cause the Appsmith instance to crash. Hence, ensure you have set up and can access an external MongoDB instance hosting MongoDB V5.0 or later. For more information, see External MongoDB.
Create EFS volume
- Navigate to the Elastic File System section of the AWS Management Console and click the Create file system button.
- On the Create file system pop-up screen:
- Name- Provide a meaningful name to your file system. For example,
appsmith-ecs-ec2-cluster-efs
. - VPC- Select the VPC in which the ECS container is running, and click Create.
- Name- Provide a meaningful name to your file system. For example,
- Select the file system you created above from the list and switch to the Network tab. Verify that the Mount target state is Available before proceeding to next step.
- Click the Manage button, and assign the security group that allows NFS access on port 2049. If you don't have such a security group:
- Follow the Create a Security Group guide and include an inbound rule for NFS access on port 2049.
- Once created, attach this security group to your EFS.
Update Appsmith task definition
Follow the below steps to configure your Appsmith task definition to use the newly created EFS:
-
Go to the AWS Management Console, open the Amazon ECS console, and select Task Definitions from the sidebar.
-
Select your existing task definition, and click the Create new revision button to create a new revision of the task definition.
-
Go to the Container-1 section, click the Add environment variable button, and add the below environment variables in Key and their values in Value:
APPSMITH_ENCRYPTION_PASSWORD
: Add a password to that you noted while taking the backup in the Prerequisites section.APPSMITH_ENCRYPTION_SALT
: Use encryption salt that you noted while taking the backup in the Prerequisites section.APPSMITH_SUPERVISOR_PASSWORD
: Password to access the supervisor console to watch the processes in the Appsmith container. It's recommended to use a random password.APPSMITH_MONGODB_URI
: Enter the URI of the external MongoDB (v5.0 or later) instance.APPSMITH_ENABLE_EMBEDDED_DB
to0
. This disables embedded mock databases on EFS volume.
-
Go to the Storage section and add a new volume with below details:
- Volume type- EFS
- Configure the Storage configurations as show below:
- Volume name- Give a meaningful name. For example,
appsmith-ecs-ec2-cluster-efs-volume
- File system ID: Select the EFS file system created in the Create EFS volume section
- Root directory:
/
- Volume name- Give a meaningful name. For example,
- Configure the Container mount points, as shown below:
- Update the Container path for Bind mount from
/appsmith-stacks
toappsmith-stacks-old
- Click Add mount point, and add details as shown below:
- Container- Choose appsmith
- Source volume- Choose the name of the EFS volume. For example,
appsmith-ecs-ec2-cluster-efs-volume
- Container path- add path as
/appsmith-stacks
- Update the Container path for Bind mount from
-
Keep default values for other settings, and click Create button.
Update Appsmith ECS service
Follow the below steps to update your Appsmith service to use the newly created task definition:
- Go to the AWS Management Console, open the Amazon ECS console, select your ECS Cluster, and go to the Services tab.
- Select your service and click the Update button.
- Check the Force new deployment checkbox
- In the Task definition, select the newly created revision for the Revision setting.
- Click the Update button to save the changes and initiate a new deployment.
- Verify the service Last status shown as Running, which means that the service is up and running.
Migrate data from Bind mount to EFS
Follow the below steps to migrate data:
-
Use the key pair created during the cluster creation process; this key pair will be necessary for connecting to your AWS account.
ssh -i <keypair.pem> -o "StrictHostKeyChecking=no" ec2-user@<task-ip>
-
Take a note of the Appsmith container ID with:
sudo docker ps -a | grep appsmith
-
Exec into the container with:
sudo docker exec -it -u root <CONTAINER-ID> bash
Replace the <CONTAINER-ID>
with Appsmith container ID. You'll see both the old and new volumes attached to the Appsmith container.
4. Copy the backup tar to the EFS volume with:
cp /appsmith-stacks-old/data/backup/*.tar /appsmith-stacks/data/backup/
-
Restore the data with:
appsmithctl restore
For more information, see Restore Appsmith.
-
Verify the Appsmith service by logging into your Appsmith account and verifying your apps.
Remove Bind mount storage
Follow the below steps to remove the Bind mount:
- Go to the AWS Management Console, open the Amazon ECS console, and select Task Definitions from the sidebar.
- Select your existing task definition, and click the Create new revision button to create a new revision for the task definition.
- In the Storage section, click the Remove button next to the volume that uses Bind mount.
- Keep default values for other settings, and click Create button.
- Update the ECS service to use the latest revision. Follow the steps in the Update Appsmith ECS service section.
- Verify the Appsmith service by logging into your Appsmith account and verifying your apps.
Troubleshooting
If errors occur, roll back to a previous version to fix the issue. For more information, see the Restore instance section.
If you continue to face issues, contact the support team using the chat widget at the bottom right of this page.