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. Go to the directory that has the docker-compose.yml file.

  2. Create a backup archive with encryption, execute the following command:

    docker-compose exec appsmith appsmithctl backup

    The above command encrypts the backup archive with a password. When prompted, enter a password and ensure you remember it. You need this password if you ever want to restore from this backup. If you forget it, you won't be able to restore this backup. The backup archive file is stored in the /appsmith-stacks/data/backup/ folder in your container directory. You can access it at ./stacks/data/backup/ on your local machine.

  3. If you can't access or have a different volume configuration, copy the archive file to your host disk with:

    # Replace the appsmith-backup-DATE_AND_TIMESTAMP.tar.gz.enc with the backup file name
    docker cp appsmith:/appsmith-stacks/data/backup/appsmith-backup-DATE_AND_TIMESTAMP.tar.gz.enc .

    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. Go to the directory where the docker.env file is located.
  2. Open the docker.env file and add the below entries:
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
  1. Sync your backups to the S3 bucket with:
docker-compose exec 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. Go to the directory that has the docker-compose.yml file.

  2. Get your encryption details with:

docker-compose exec appsmith cat /appsmith-stacks/configuration/docker.env | grep ENCRYPTION

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

  1. Create a backup archive with:
docker-compose exec appsmith appsmithctl export_db

The backup archive file is stored in the /appsmith-stacks/data/backup/ folder in your container directory. You can access it at ./stacks/data/backup/ on your local machine.

  1. If you can't access or have a different volume configuration, copy the archive file to your host disk with:
docker cp appsmith:/appsmith-stacks/data/backup/appsmith-data.archive .

This command copies the backup archive in your current directory.

  1. To recreate the same environment elsewhere, copy the docker.env file with:
docker cp appsmith:/appsmith-stacks/configuration/docker.env .

This command copies the docker.env file in your current directory.

Restore instance

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

  1. Restore your Appsmith instance with:
docker-compose exec appsmith appsmithctl restore

The command lists backup archives in the folder, with the latest backup at the bottom.

  1. Select the backup archive from the given list of backup archives to restore.
Select a backup archive while restoring Appsmith instance
Select a backup archive while restoring Appsmith instance
Attention

If you restore an older version of Appsmith, a warning message may appear. Update the docker-compose.yml file with the Appsmith image you wish to restore.

  1. You can either use the existing encryption or create new values for:
    • APPSMITH_ENCRYPTION_PASSWORD
    • APPSMITH_ENCRYPTION_SALT
Option to use existing encryption values
Option to use existing encryption values

Restore database

Follow these steps to restore the Appsmith internal database:

  1. Copy the archive file into the container with:
docker cp ./appsmith-data.archive appsmith:/appsmith-stacks/data/restore/
  1. Import data from the backup archive file with:
docker-compose exec appsmith appsmithctl import_db
  1. Copy the docker.env file with:
# Add the path for the docker.env file if not present in the installation folder
docker cp ./docker.env appsmith:/appsmith-stacks/configuration/
  1. Restart the Appsmith server with:
docker-compose exec appsmith supervisorctl restart backend

Troubleshooting

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