PageSourceSearch

https://postgres.ai/assets/js/b0d2bdf2.aaa5be12.js

js postgres.ai collected 2026-10-02 05:24:57 UTC 9,448 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkdatabase_lab_docs=self.webpackChunkdatabase_lab_docs||[]).push([["29594"],{95532(e,n,a){a.r(n),a.d(n,{metadata:()=>t,default:()=>h,frontMatter:()=>c,contentTitle:()=>s,toc:()=>d,assets:()=>o});var t=JSON.parse('{"id":"dblab-howtos/branching/delete-branch","title":"How to delete a database branch","description":"Delete a database branch in DBLab Engine from the GUI, the dblab branch command, or the API; protect a branch from deletion or let the retention policy expire unused branches automatically (DBLab Engine 4.2+).","source":"@site/docs/dblab-howtos/branching/delete-branch.md","sourceDirName":"dblab-howtos/branching","slug":"/dblab-howtos/branching/delete-branch","permalink":"/docs/dblab-howtos/branching/delete-branch","draft":false,"unlisted":false,"editUrl":"https://gitlab.com/postgres-ai/docs/-/edit/master/docs/dblab-howtos/branching/delete-branch.md","tags":[],"version":"current","frontMatter":{"title":"How to delete a database branch","sidebar_label":"Delete a database branch","description":"Delete a database branch in DBLab Engine from the GUI, the dblab branch command, or the API; protect a branch from deletion or let the retention policy expire unused branches automatically (DBLab Engine 4.2+)."},"sidebar":"baseSidebar","previous":{"title":"Create a database branch","permalink":"/docs/dblab-howtos/branching/create-branch"},"next":{"title":"Preview environments with Coolify","permalink":"/docs/dblab-howtos/branching/preview-environments-with-dblab-and-coolify"}}'),r=a(74848),i=a(28453);let c={title:"How to delete a database branch",sidebar_label:"Delete a database branch",description:"Delete a database branch in DBLab Engine from the GUI, the dblab branch command, or the API; protect a branch from deletion or let the retention policy expire unused branches automatically (DBLab Engine 4.2+)."},s,o={},d=[{value:"GUI",id:"gui",level:2},{value:"CLI",id:"cli",level:2},{value:"Reference",id:"reference",level:3},{value:"Delete branch",id:"delete-branch",level:3},{value:"Protect a branch from deletion (DBLab Engine 4.2+)",id:"protect-a-branch-from-deletion-dblab-engine-42",level:2},{value:"GUI",id:"gui-1",level:3},{value:"CLI",id:"cli-1",level:3},{value:"API",id:"api",level:3},{value:"Automatic deletion of unused branches (DBLab Engine 4.2+)",id:"automatic-deletion-of-unused-branches-dblab-engine-42",level:2},{value:"Related",id:"related",level:2}];function l(e){let n={a:"a",admonition:"admonition",code:"code",h2:"h2",h3:"h3",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,i.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.admonition,{type:"info",children:(0,r.jsxs)(n.p,{children:["DBLab Engine must be version ",(0,r.jsx)(n.code,{children:"4.0"})," or higher."]})}),"\n",(0,r.jsx)(n.h2,{id:"gui",children:"GUI"}),"\n",(0,r.jsxs)(n.ol,{children:["\n",(0,r.jsxs)(n.li,{children:["Go to the ",(0,r.jsx)(n.strong,{children:"Database Lab instance"})," page."]}),"\n",(0,r.jsxs)(n.li,{children:["Choose the Branches tab.\n",(0,r.jsx)(n.img,{alt:"Database Lab instance page / Delete branch",src:a(79345).A+"",width:"1438",height:"758"})]}),"\n",(0,r.jsxs)(n.li,{children:["Click on the branch you want to delete.\n",(0,r.jsx)(n.img,{alt:"Database Lab instance page / Delete branch",src:a(36278).A+"",width:"1292",height:"562"})]}),"\n",(0,r.jsxs)(n.li,{children:["Click on ",(0,r.jsx)(n.strong,{children:"Delete branch"}),".\n",(0,r.jsx)(n.img,{alt:"Database Lab instance page / Delete branch",src:a(26957).A+"",width:"1398",height:"1072"})]}),"\n",(0,r.jsxs)(n.li,{children:["You will be asked to confirm the deletion.\n",(0,r.jsx)(n.img,{alt:"Database Lab instance page / Delete branch",src:a(84452).A+"",width:"922",height:"388"})]}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"cli",children:"CLI"}),"\n",(0,r.jsxs)(n.p,{children:["Before you run any commands, install the DBLab CLI and initialize the configuration. For more information, see ",(0,r.jsx)(n.a,{href:"/docs/dblab-howtos/cli/cli-install-init",children:"Install and initialize DBLab CLI"}),"."]}),"\n",(0,r.jsx)(n.h3,{id:"reference",children:"Reference"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["Command ",(0,r.jsx)(n.a,{href:"/docs/reference-guides/dblab-client-cli-reference#command-branch",children:(0,r.jsx)(n.code,{children:"dblab branch"})})]}),"\n"]}),"\n",(0,r.jsx)(n.h3,{id:"delete-branch",children:"Delete branch"}),"\n",(0,r.jsxs)(n.p,{children:["Delete a database branch with the ",(0,r.jsx)(n.code,{children:"dblab branch"})," command, using ",(0,r.jsx)(n.code,{children:"-d"})," or ",(0,r.jsx)(n.code,{children:"--delete"}),":"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-bash",children:"$ dblab branch -d test\n"})}),"\n",(0,r.jsx)(n.h2,{id:"protect-a-branch-from-deletion-dblab-engine-42",children:"Protect a branch from deletion (DBLab Engine 4.2+)"}),"\n",(0,r.jsxs)(n.p,{children:["A protected branch cannot be deleted manually and is skipped by the automatic ",(0,r.jsx)(n.a,{href:"#automatic-deletion-of-unused-branches-dblab-engine-42",children:"retention sweep"}),". Protection uses the same lease grammar as ",(0,r.jsx)(n.a,{href:"/docs/dblab-howtos/cloning/clone-protection",children:"clone protection"}),": a number of minutes or a duration such as ",(0,r.jsx)(n.code,{children:"30m"}),", ",(0,r.jsx)(n.code,{children:"2h"}),", ",(0,r.jsx)(n.code,{children:"7d"}),"; ",(0,r.jsx)(n.code,{children:"true"})," or ",(0,r.jsx)(n.code,{children:"0"})," for no expiry; ",(0,r.jsx)(n.code,{children:"false"})," to remove it. Branches and snapshots have no default lease. When the administrator sets ",(0,r.jsx)(n.code,{children:"retention.protectionMaxDurationMinutes"})," (no cap by default), ",(0,r.jsx)(n.code,{children:"true"})," and ",(0,r.jsx)(n.code,{children:"0"})," yield a lease equal to that cap and longer requests are shortened to it."]}),"\n",(0,r.jsx)(n.h3,{id:"gui-1",children:"GUI"}),"\n",(0,r.jsxs)(n.p,{children:["On the ",(0,r.jsx)(n.strong,{children:"Database Lab branch"})," page, set the ",(0,r.jsx)(n.strong,{children:"Deletion protection"})," dropdown to the desired duration."]}),"\n",(0,r.jsx)(n.h3,{id:"cli-1",children:"CLI"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-bash",children:"# Protect for 7 days\n$ dblab branch --protected 7d test\n\n# Protect with no expiry\n$ dblab branch --protected 0 test\n\n# Remove protection\n$ dblab branch --protected false test\n"})}),"\n",(0,r.jsxs)(n.p,{children:["The list output annotates protected branches with ",(0,r.jsx)(n.code,{children:"[protected]"})," or ",(0,r.jsx)(n.code,{children:"[protected until <time>]"}),"."]}),"\n",(0,r.jsx)(n.h3,{id:"api",children:"API"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-bash",children:'curl -X PATCH \\\n  -H "Verification-Token: YOUR_TOKEN" \\\n  -H "Content-Type: application/json" \\\n  -d \'{"protected": true, "protectionDurationMinutes": 10080}\' \\\n  http://localhost:2345/branch/test\n'})}),"\n",(0,r.jsx)(n.h2,{id:"automatic-deletion-of-unused-branches-dblab-engine-42",children:"Automatic deletion of unused branches (DBLab Engine 4.2+)"}),"\n",(0,r.jsxs)(n.p,{children:["When ",(0,r.jsx)(n.code,{children:"retention.unusedBranchMinutes"})," is set to a non-zero value in ",(0,r.jsx)(n.code,{children:"server.yml"}),", the engine deletes a branch that has stayed unused for that long. A branch is unused when it has no clones and no child branches; the timer starts when the sweeper first sees it in that state and is cleared if a clone or child branch appears. Protected branches and the default branch ",(0,r.jsx)(n.code,{children:"main"})," are never removed, and pools without branch metadata (LVM) are not swept. The setting is off by default, and enabling it requires an engine restart. See the ",(0,r.jsxs)(n.a,{href:"/docs/reference-guides/database-lab-engine-configuration-reference#section-retention-automatic-deletion-of-unused-branches-and-snapshots",children:[(0,r.jsx)(n.code,{children:"retention"})," section"]})," of the configuration reference."]}),"\n",(0,r.jsx)(n.h2,{id:"related",children:"Related"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["Guide: ",(0,r.jsx)(n.a,{href:"/docs/dblab-howtos/branching/create-branch",children:"Create a database branch"})]}),"\n",(0,r.jsxs)(n.li,{children:["Guide: ",(0,r.jsx)(n.a,{href:"/docs/dblab-howtos/cloning/clone-protection",children:"Protect clones from deletion"})]}),"\n"]})]})}function h(e={}){let{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(l,{...e})}):l(e)}},79345(e,n,a){a.d(n,{A:()=>t});let t=a.p+"assets/images/create-branch-1-efec7db37d05e1aba59180e00c550675.png"},36278(e,n,a){a.d(n,{A:()=>t});let t=a.p+"assets/images/delete-branch-1-3e5e742caf915dcbddcdb3e3b7111b70.png"},26957(e,n,a){a.d(n,{A:()=>t});let t=a.p+"assets/images/delete-branch-2-ccc748f1fecd333342089e2b4f8c6037.png"},84452(e,n,a){a.d(n,{A:()=>t});let t=a.p+"assets/images/delete-branch-3-27e7548428c5deee74c79f2874f12a58.png"},28453(e,n,a){a.d(n,{R:()=>c,x:()=>s});var t=a(96540);let r={},i=t.createContext(r);function c(e){let n=t.useContext(i);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function s(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:c(e.components),t.createElement(i.Provider,{value:n},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.