#Keeping dev branches in sync

1 messages · Page 1 of 1 (latest)

plucky pollen
#

I'm trying to maintain dev/test instances of Twenty. What is the best approach to keeping them in sync with prod? Does only the databse need to be copied over to clone the instance?

runic wadiBOT
#
Searched sync dev test production instances database clone
#
Searched environment setup configuration deployment
#

The documentation doesn't have a specific guide for cloning/syncing instances between environments, but based on what's covered, here's what you need to know:

It's not just the database. To fully clone a Twenty instance, you need to account for these components:

  • PostgreSQL database -- This is the primary data store containing your workspace data, metadata, and (if IS_CONFIG_VARIABLES_IN_DB_ENABLED=true, which is the default) your configuration variables. This is the most critical piece.
  • Redis cache -- Twenty uses Redis for caching. After restoring a database to a new instance, you should flush the cache to avoid stale/inconsistent data:
    yarn command:prod cache:flush
    
  • Server local data volume -- If you're storing files/attachments locally (the server-local-data volume in Docker Compose), you'll need to copy that as well.
  • Environment variables / .env file -- Infrastructure settings like SERVER_URL, APP_SECRET, PG_DATABASE_URL, and REDIS_URL are configured via .env and will differ between environments. Make sure your dev/test .env points to the correct URLs and services.

Recommended approach for syncing prod to dev/test:

  1. Dump the prod database:

    docker exec -it {db_container} pg_dumpall -U {postgres_user} > databases_backup.sql
    
  2. Restore to your dev/test database:

    cat databases_backup.sql | docker exec -i {dev_db_container} psql -U {postgres_user}
    
  3. Copy the file storage volume if you use local storage for attachments.

  4. Flush the Redis cache on the dev/test instance:

    yarn command:prod cache:flush
    
  5. Ensure your dev/test .env has the correct SERVER_URL and other infrastructure variables for that environment.