How Lakebase Branching Works: Zero-Copy Database Branches for Dev, CI and Staging
Summary
- Zero-copy clones: copy-on-write branching creates disposable development databases in seconds.
- Isolated branches: developers, CI and staging get branches that share data without copying.
- Point-in-time recovery: restore branches enable safe schema changes and bug reproduction without touching production.
How Lakebase Branching Works: Zero-Copy Database Branches for Dev, CI and Staging

Talk by Anna Stepanyan, Staff Product Manager (Lakebase), Databricks
Database branching in Postgres on Databricks Lakebase creates an isolated, zero-copy clone of a database in seconds using copy-on-write storage, so every feature branch, pull request or developer can have their own database. Because a branch shares data with its parent instead of copying it, development databases become cheap and disposable. This video covers branching across local development, CI and staging, reproducing a production bug on a branch, instant restore branches for point-in-time recovery, and testing schema changes safely.
Anna Stepanyan, Staff Product Manager for Lakebase, shows how branching fits local development, CI pipelines and staging: create a branch per pull request and delete it when the PR closes, give each developer a branch from a template with initial data, reproduce a production error on a branch, test schema changes before touching production, and recover to the moment before a bad change with point-in-time recovery. A demo runs three parallel coding agents, each with its own git working tree and its own database branch, then compares the data across branches. Lakebase instances and branches also scale to zero when idle.
Chapters
00:00Introduction00:31Lakebase: a developer-friendly Postgres database02:25Zero-copy branching with copy-on-write03:40Branching across dev, test and production workflows05:37Reproduce a production bug on a database branch06:50Point-in-time recovery with instant restore branches08:05Test schema changes and CI on a temporary branch09:54A database branch per pull request in staging11:09A database branch per developer from a template12:24Parallel coding agents, each with its own database branch15:03Comparing data across branches18:22Moving branches between workspaces and masking data
FAQs
How does Lakebase branching work?
Database branches use copy-on-write storage to create zero-copy clones in seconds. Each branch shares data with its parent database, so new branches cost almost nothing and development becomes cheap and disposable.
Can I reproduce a production bug on a branch?
Yes—create a branch from your production database, reproduce the bug in that isolated environment, test your fix, and then run it safely without touching live data. Point-in-time recovery branches let you restore to any moment.
How do I test schema changes safely?
Create a temporary database branch and test schema changes there before applying them to production. Because branches are cheap and isolated, you can safely experiment without worrying about impact.
Can branches scale to zero?
Yes—Lakebase instances and branches scale to zero when idle, so development and staging databases don't incur costs when not in use. The entire demo ran three parallel coding agents on separate branches.
Full transcript
00:00 Introduction
OK. Hello everyone. Can you hear me? Can you hear me? My name is Anna. I'm a product manager on the Lake Base team, and today I want to share some practical tips and workflows on how you can implement database forking , Lake Base forking today. Looking back, I've been with Lake Base almost from the beginning, back when it was Neon. And since then, we've been very focused on developer friendliness. Our mission was to create the best database that developers love and have no problems with.
00:31 Lakebase: a developer-friendly Postgres database
Over time, we discovered that agents' needs are not much different from humans', and they value the same things. A key factor for these ergonomics is our architecture of separating storage and compute resources. Because computations are decoupled, they become ephemeral and elastic. Now a new Lake Base is created in a second. Imagine a database: you blink your eyes and it's ready. You don't have to wait weeks for a ticket from the IT team or hours for cloud providers to provide you with a database.
So, Lake Base is created in a second and reduces computing resources when they are inactive. No extra costs, and it goes into sleep mode if not used right away. By the way, by default, Lake Base is created today with scaling settings set to zero. So even if you tried Lake Base for POC, it scales down if your POC is suspended. You won't suddenly get a bill from Databricks for all those Lake Base auto-scaling databases running.
Okay, the storage tier has also undergone its own innovations. Git and the dream of time travel inspired us to create a fork for databases. Branches also scale to zero, "wake up" and are created instantly, similar to an empty Lake Base, but the branch is not created empty. It shares data with the parent database: the same pages that were in the parent are present and visible to the branch. This instant "wake-up" is possible because the branch does not copy any data.
02:25 Zero-copy branching with copy-on-write
It shares data with the parent database. This is copy-on-write. This makes development databases very cheap, disposable, and easy to use, like Git branches. And often people ask, "So if it's like a Git branch, can it also be merged?" My answer to them is: resolving merge conflicts is not something that is very simple in code. When you're working with just a few lines of code, this can become a daunting task. Imagine if you had to reconcile changes between hundreds or thousands of pages.
In a heavily loaded database, your working instance may change significantly, creating thousands or even millions of pages. And now someone has to reconcile all of this and decide what to keep. You are not merging the database. Instead, you track the schema of this database along with the code in your application in Git. You are uniting just that. But the database, that branch you created, is ephemeral. It is temporary.
Once you're done developing or testing, you delete it. Hmm, so how do I delete it? How do you decommission a branch ? I will give you a plan of action. Many of you probably already have a workspace for your development environment, a separate one for testing or user acceptance testing, and another one for your production environment. Raise your hands, please. Who divides workspaces by environment? Yes, most of you here.
03:40 Branching across dev, test and production workflows
Okay, that's nice to hear. Then this action plan will be useful for you . So, the workspace is your environment. And Lake Base projects seem to be placed inside the workspace. And branches live inside these projects. And since each workspace has its own environment, you will have different workflows or use cases based on branching. In development, everyone will create a branch from a baseline or template that contains all of your initial data.
In a testing environment, you'll likely have a shared instance that everyone wants to access to try out things and see the latest developments that have n't made it to production yet. During user acceptance testing, you will probably create branches for each test run, or perhaps a set of tests. Finally, there are use cases for a production environment as well, when you want to test changes before implementing them or reproduce an issue.
Well , okay. Is there anyone who has one workspace for all their environments? No one. Of course. Well , your life could be a little easier, but most customers really need to separate environments, serious workloads even require network isolation. So it's totally okay if you're not in that category. Most customers will have isolated environments, and that's what this plan is about. So, let's look at the first use case in more detail.
05:37 Reproduce a production bug on a database branch
We want to reproduce the error in a production environment, maybe there was an error, you got a notification, someone said, "Hey, I see a 500 error." You open it an hour later and can't play it anymore. In fact, it is possible that the 500 error was reproduced or seen on an entity page that has already been deleted and is no longer in the database. So, what do you do? You create a new branch of the working environment from the exact moment the error occurred.
You probably have a timestamp of the error or a message when you were notified of it , right? You reproduce the problem on real data: you plug the application into this branch, reproduce the problem, find the cause, apply the fix, test it on this branch before deploying the code to the production environment. When this entire cycle is complete, you delete the created branch. You don't need her anymore. And then data recovery.
Similar scenario, another rescue. Something broke recently, but maybe this time you lost data . Maybe it was a failed migration, a bad schema change. You didn't realize that someone was using that spreadsheet you created recently. You tried to clean it, and, yes, things did n't go according to plan. So, what do you do then? You create a new branch from the moment immediately before the data loss. You extract the data you need from this restored copy and move it to the working branch.
06:50 Point-in-time recovery with instant restore branches
After this, the recovery is complete. Everything is finished. You are deleting the branch that was used for the restore. You can do this without creating branches. Many cloud providers offer point-in- time database recovery, but LakeFS's unique storage architecture allows you to create such recovery instances in a second, just like any other branch. So you don't need to wait for the system to load the snapshot and recreate the transaction log over it.
This is a typical problem when restoring a working environment from other providers. OK. So, with LakeFS, you will recover quickly. No need to wait. The story is sad, but can we even prevent this? I don't want to see such unfortunate schema changes in the production environment. Working with branches helps with this too. Before making any changes, including schema changes, to your production environment, why not create a new temporary branch where you test this migration?
08:05 Test schema changes and CI on a temporary branch
You test the schema change on production data. You might even launch the application, make sure all pages load, and run a set of tests. And when the test is complete and you are sure that you have not lost any data, you can apply the schema change to real production and delete the temporary branch created in your CI. Perfectly. Okay . Another scenario is user acceptance testing (UAT). It has the same structure as the cases I showed for production: creating a temporary branch and then deleting it.
Here you branch off of what I call “UAT main,” creating a separate branch for each tester or test suite. Each branch here starts with a known and identical state, so the tests do not interfere with each other. So, you create a new branch knowing the initial state, run a set of tests on your ideal dataset, and after testing is complete, you reset the branch or delete it. You regularly update your "UAT main ". I would recommend doing this every time you deploy to production.
Run the same schema changes as you do in production on all your other environments. Your CI/CD system will take care of this for you. Okay, another use case is staging, where maybe new features are actively being developed and pull requests are coming in every day. How can creating branches help here? When a pull request is opened , we can create a database branch to stage that request to get a preview. Now another engineer isn't just looking at changes in the code, he has a working application with the changes that uses his own database.
09:54 A database branch per pull request in staging
So, we can test functions in isolation. We don't need to deal with this fragile staging environment that everyone uses. And when the pull request is closed, the branch is deleted. We don't need her anymore. Ahem. After closing the pull request, you will probably want to apply these changes to your "staging main". It's like a template on which all pull requests are created . Therefore, it is important to keep it working and up-to-date with the database schema.
Okay, we're getting close to my favorite use cases. If we can provide a branch for each pull request or test suite, can we give a branch to each developer? Of course. So, in this case, we will have a template, the initial data from which each developer creates branches. Anna, Sam, and Lee—each of them has their own database. And if your company provides virtual machines as development environments, you no longer need to manage a database for each one.
11:09 A database branch per developer from a template
So, again, each developer has a branch, and that branch is isolated from the others. She has her own credentials, etc. Each developer works on this specific branch. And when it's time to clean up or start a new feature, they reset that branch or update it from the original data , and start from a clean state. Okay . Good. Now my favorite. With the development of AI, developers have coding agents that help them write code.
So what should we do about this? Now we need even more copies. So, branching allows each agent to also get its own branch of the database. Just as each agent gets its own Git working directory, the database is dedicated and isolated from other branches. Let me show you this in a demo. Good. OK. In this example, I have this application in Python. This is a small program, just a coffee shop that does e- commerce. Let me run it locally to show you how it works.
12:24 Parallel coding agents, each with its own database branch
If you saw my morning talk, it's essentially the same application. We sell coffee. We have a mix here with data-driven auto-scaling. It has a little Neon tint so we can see past orders. And this instance is already running on the dedicated branch. This is my branch. No one else is working on it . But now I want to start developing with agents. So, I have a specification for a feature I want to develop. I wish we could add grind size and one more feature.
What I want to say here is: add a rating for purchased products. Finally, another feature adds unique promo codes that provide discounts after placing an order. So, I want to run three agents in parallel to create these features. And ideally they should not interfere with each other. You can see that the agents have already picked up on the idea of creating a database branch for each working directory, working in parallel.
Agents understand that they are working on Databricks Lakehouse and know how to use it and our CLI. Agent C also realized this, and now understands that his job will involve changing the schema, adding columns and tables. Additionally, they picked up on the idea of using Git working trees, and Agent B will now create a Git working tree. Let 's take a look. Other agents do not connect as quickly as agent B. This is perhaps the easiest feature to develop.
Uh-huh. Let 's take a look. So, two agents have already created a database branch for themselves . We are looking at the Lakehouse console. And we see the two branches they created for themselves. There are two working trees locally. Now they start writing code. They have completed the implementation, their CSS is ready. We are getting closer to seeing the program in action. Okay, the third agent has connected, now we have three working trees, and we will see three database branches in the Lakehouse console.
15:03 Comparing data across branches
Let's compare the data in these branches. So, product ratings in an order are one of the agents. Yeah, okay , the other database doesn't have this table, product ratings in the order. And what does the third database show ? Promo codes. So, you see the difference. Each of them created a table in their own branch. Okay, everything seems to be working fine, but I asked each agent to run a live version so I could test it.
And it seems that this is the agent who creates the ratings. Yes, I can't rate my order. There is some error there. I think the agent can fix it. So I pass on this mistake to him and watch the others. Another agent finally created a new column in an already existing table. There is a "grind" option. And each of the agents will launch a local version for me. So , this is the agent who implemented the ratings. The ratings are here.
They are also available for past orders. Perfectly. So, the migration scheme change has been successfully completed. This is the result of the work of another agent. He added the grind size. Let's check past orders. There is a grind size, but no rating. So, these are different databases, different applications, completely isolated development environments. Uh, the third agent will be able to handle it soon. I will try and believe in it.
In the meantime, I can ask these agents to create a pull request for me . So, two agents are ready. The third one is about to catch up. I think you understand, right? So the third agent finally finished with the promo codes. Now I will get a discount. Let's see if it works. I can place an order to get my first promo code. Now let's check if using the promo code will work and if I will get a discount. Oh. Yes. I just got six dollars off my order.
This is how the three agents worked independently of each other. Everyone ran an environment so I could see their results. Everyone will create a pull request describing their changes. And all of this is possible thanks to Git working trees and such branching. OK. So, we showed you how to go from a shared database to an environment where there was a mix of features and you weren't even sure what you were testing. We've moved to a new way where we have a branch for each change, isolated in its own environment.
And now the database moves at the speed of the rest of your stack. I'm sure you still have questions . You may want to know if you can move data or a branch from one workspace to another. You may want to anonymize the data when creating a branch. That is, hide or mask sensitive data in your database. Help us develop our product further. We appreciate your input. This is an invitation to explore, where we may ask you questions about your workflows, challenges, and how we can improve your life.
18:22 Moving branches between workspaces and masking data
Thank you.
Learn more about the Databricks Data and AI platform.
The information provided herein is for general informational purposes only and may not reflect the most current product capabilities or configurations.