Skip to main content

Backup and Restore

Appsmith comes with the appsmithctl command line utility. You can use the command line to interact with and manage your self-hosted instance. For example, back up and restore your Appsmith instance and database. This page provides steps to run the backup and restore commands.

How to use Appsmithctl for Docker

Usage

appsmithctl <subcommand> <options>

Subcommands

Subcommands allow you to trigger different operations like exporting or importing databases.

SubcommandDescription
--helpShows available subcommands and how to use appsmithctl
backupCreates a backup of the Appsmith instance
ex, export_dbCreates a backup of Appsmith internal database
--upload-to-s3Upload the back up files to S3 bucket (Commercial Edition only)
restoreRestores the Appsmith instance from a backup
im, import_dbRestores the Appsmith internal database

Prerequisites

  • The self-hosted instance should be up and running. If you haven't already installed Appsmith, refer to the Installation guides.
  • Access to execute docker-compose or kubectl commands

Backup instance

You can create a backup archive of the Appsmith instance. The backup includes the database, docker.env, and Git data. Follow these steps to create a backup archive:

  1. Get the name of the Appsmith pod with (replace the APPSMITH_NAMESPACE with your Appsmith namespace):
kubectl get pods -n APPSMITH_NAMESPACE
  1. Get your encryption details using the below command (replace the ANY_APPSMITH_POD_NAME with your Appsmith pod name):
kubectl exec ANY_APPSMITH_POD_NAME -- cat /appsmith-stacks/configuration/docker.env | grep ENCRYPTION

Keep these details handy, as you need them for restoring the Appsmith instance.

  1. Create a backup using the below command (replace the ANY_APPSMITH_POD_NAME with your Appsmith pod name):
kubectl exec ANY_APPSMITH_POD_NAME appsmithctl backup

The archive file is stored in the container directory /appsmith-stacks/data/backup/.

  1. Copy the archive file using the below command, ensure that you replace the ANY_APPSMITH_POD_NAME with your Appsmith pod name, APPSMITH_BACKUP_FILENAME with your Appsmith backup filename, and APPSMITH_NAMESPACE with your Appsmith namespace:
kubectl cp ANY_APPSMITH_POD_NAME:/appsmith-stacks/data/backup/APPSMITH_BACKUP_FILENAME -n APPSMITH_NAMESPACE GIVE_NAME_FOR_COPIED_BACKUP_FILE

After running the above command, the backup archive is copied to your current directory, indicating that the backup process is completed. You can now proceed with the remaining steps of the process you were performing.

Schedule automatic backups

Docker

Follow these steps to schedule backups only for Docker Appsmith installation:

  1. Go to the directory where the docker.env file is located.
  2. Open the docker.env file and set the environment variable as shown below:
# Add a 5-value cron expression
APPSMITH_BACKUP_CRON_EXPRESSION="ADD_5_VALUE_CRON_EXPRESSION"
Examples
  • To schedule a backup at 12:00 noon on Sunday:
APPSMITH_BACKUP_CRON_EXPRESSION="0 12 * * SUN"
  • To schedule a backup daily at Midnight:
APPSMITH_BACKUP_CRON_EXPRESSION="0 0 * * *"

For more information about creating the Cron expressions, see Cron Schedule Expression Editor.

Sync backup to S3 bucket

Follow these steps to sync backups with an S3 bucket for your installation type:

  1. Set the Amazon S3 bucket:

    • Using the command:
    helm upgrade \
    --set applicationConfig.APPSMITH_BACKUP_S3_ACCESS_KEY=AWS_ACCESS_KEY \
    --set applicationConfig.APPSMITH_BACKUP_S3_SECRET_KEY=<AWS_SECRET_KEY \
    --set applicationConfig.APPSMITH_BACKUP_S3_BUCKET_NAME=BUCKET_NAME \
    --set applicationConfig.APPSMITH_BACKUP_S3_REGION=AWS_BUCKET_REGION \
    appsmith appsmith/appsmith
    • Or using values.yaml file:

      a. Update the parameter values in the values.yaml file under the applicationConfig section:

      applicationConfig:
      APPSMITH_BACKUP_S3_ACCESS_KEY=AWS_ACCESS_KEY
      APPSMITH_BACKUP_S3_SECRET_KEY=AWS_SECRET_KEY
      APPSMITH_BACKUP_S3_BUCKET_NAME=BUCKET_NAME
      APPSMITH_BACKUP_S3_REGION=AWS_BUCKET_REGION

      b. Update the values:

      helm upgrade appsmith appsmith-ee/appsmith -f values.yaml 
  2. Get the name of the Appsmith pod with:

kubectl get pods
  1. Sync your backups to the S3 bucket with:
# Replace `ANY_APPSMITH_POD_NAME` with the pod name
kubectl exec ANY_APPSMITH_POD_NAME appsmithctl backup --upload-to-s3

After configuration, the restore command lists local and S3 bucket backups.

Backup database

Follow these steps to back up your Appsmith internal database:

Attention

Ensure that the name of the backup archive (appsmith-data.archive) isn't changed.

  1. Get the name of the Appsmith pod with:
kubectl get pods
  1. Get your encryption details with:
# Replace `ANY_APPSMITH_POD_NAME` with the pod name
kubectl exec ANY_APPSMITH_POD_NAME -- cat /appsmith-stacks/configuration/docker.env | grep ENCRYPTION

Keep these details handy, as you need them for restoring the Appsmith database.

  1. Create a database backup with:
# Replace `ANY_APPSMITH_POD_NAME` with the pod name
kubectl exec ANY_APPSMITH_POD_NAME appsmithctl export_db

The archive file is stored in the container directory /appsmith-stacks/data/backup/.

  1. Copy the archive file with:
# Replace `ANY_APPSMITH_POD_NAME` with the pod name
kubectl cp ANY_APPSMITH_POD_NAME:/appsmith-stacks/data/backup/appsmith-data.archive appsmith-data.archive

Restore instance

Follow these steps to restore your Appsmith instance from a backup archive:

  1. Get the name of the Appsmith pod with:
kubectl get pods
  1. Copy the archive file to the pod with:
# Replace `ANY_APPSMITH_POD_NAME` with the pod name
kubectl cp appsmith-backup-TIMESTAMP.tar.gz ANY_APPSMITH_POD_NAME:/appsmith-stacks/data/backup/
  1. Go to the /appsmith-stacks/configuration/ folder

  2. Open the docker.env file and update the below parameters:

# The one you generated and stored while creating a backup
APPSMITH_ENCRYPTION_PASSWORD=APPSMITH_ENCRYPTION_PASSWORD
APPSMITH_ENCRYPTION_SALT=APPSMITH_ENCRYPTION_SALT
  1. Restore the backup with:
# Replace `ANY_APPSMITH_POD_NAME` with the pod name
kubectl exec ANY_APPSMITH_POD_NAME appsmithctl restore
  1. Restart the Appsmith pods:

    a. When autoscaling is turned off, or you are using a Community Edition with:

    kubectl rollout restart statefulset appsmith

    b. When autoscaling is turned on with:

    kubectl rollout restart deployment appsmith

Restore database

Follow these steps to restore the Appsmith internal database:

  1. Get the name of the Appsmith pod with:
kubectl get pods
  1. Copy the archive file into the container with:
# Replace `ANY_APPSMITH_POD_NAME` with the pod name
kubectl cp ./appsmith-data.archive ANY_APPSMITH_POD_NAME:/appsmith-stacks/data/restore/
  1. Go to the /appsmith-stacks/configuration/ folder

  2. Open the docker.env file and update the below parameters:

# The one you generated and stored while creating a backup
APPSMITH_ENCRYPTION_PASSWORD=APPSMITH_ENCRYPTION_PASSWORD
APPSMITH_ENCRYPTION_SALT=APPSMITH_ENCRYPTION_SALT
  1. Import data from the archive file with:
# Replace `ANY_APPSMITH_POD_NAME` with the pod name
kubectl exec ANY_APPSMITH_POD_NAME appsmithctl import_db
  1. Restart the Appsmith pods:

    a. When autoscaling is turned off, or you are using a Community Edition with:

    kubectl rollout restart statefulset appsmith

    b. When autoscaling is turned on with:

    kubectl rollout restart deployment appsmith

Troubleshooting

If you face issues, contact support@appsmith.com.