[{"data":1,"prerenderedAt":3281},["ShallowReactive",2],{"navigation_docs":3,"-guides-run-back-up-and-restore":520,"-guides-run-back-up-and-restore-surround":3276},[4,28,51,191,222,485],{"title":5,"path":6,"stem":7,"children":8},"Get started","\u002Fget-started","1.get-started",[9,12,16,20,24],{"title":10,"path":6,"stem":11},"Overview","1.get-started\u002Findex",{"title":13,"path":14,"stem":15},"Why Kraft","\u002Fget-started\u002Fwhy-kraft","1.get-started\u002F0.why-kraft",{"title":17,"path":18,"stem":19},"Install","\u002Fget-started\u002Finstall","1.get-started\u002F1.install",{"title":21,"path":22,"stem":23},"Your first work item","\u002Fget-started\u002Ffirst-work-item","1.get-started\u002F2.first-work-item",{"title":25,"path":26,"stem":27},"FAQ","\u002Fget-started\u002Ffaq","1.get-started\u002F3.faq",{"title":29,"path":30,"stem":31,"children":32},"Concepts","\u002Fconcepts","2.concepts",[33,35,39,43,47],{"title":10,"path":30,"stem":34},"2.concepts\u002Findex",{"title":36,"path":37,"stem":38},"How a work item runs","\u002Fconcepts\u002Fhow-a-work-item-runs","2.concepts\u002F1.how-a-work-item-runs",{"title":40,"path":41,"stem":42},"Caps and budgets","\u002Fconcepts\u002Fcaps-and-budgets","2.concepts\u002F2.caps-and-budgets",{"title":44,"path":45,"stem":46},"Why a permission gate","\u002Fconcepts\u002Fpermission-gate","2.concepts\u002F3.permission-gate",{"title":48,"path":49,"stem":50},"Vocabulary","\u002Fconcepts\u002Fvocabulary","2.concepts\u002F4.vocabulary",{"title":52,"path":53,"stem":54,"children":55},"Guides","\u002Fguides","3.guides",[56,58,96,117,138,187],{"title":10,"path":53,"stem":57},"3.guides\u002Findex",{"title":59,"path":60,"stem":61,"children":62,"page":95},"Day to day","\u002Fguides\u002Fday-to-day","3.guides\u002F1.day-to-day",[63,67,71,75,79,83,87,91],{"title":64,"path":65,"stem":66},"The setup wizard on first start","\u002Fguides\u002Fday-to-day\u002Ffirst-run","3.guides\u002F1.day-to-day\u002F2.first-run",{"title":68,"path":69,"stem":70},"File a work item","\u002Fguides\u002Fday-to-day\u002Ffile-a-work-item","3.guides\u002F1.day-to-day\u002F3.file-a-work-item",{"title":72,"path":73,"stem":74},"Use Kraft from your agent","\u002Fguides\u002Fday-to-day\u002Fagent-integration","3.guides\u002F1.day-to-day\u002F4.agent-integration",{"title":76,"path":77,"stem":78},"Reviewing a change","\u002Fguides\u002Fday-to-day\u002Freview-a-change","3.guides\u002F1.day-to-day\u002F5.review-a-change",{"title":80,"path":81,"stem":82},"Raise a cap on a stopped item","\u002Fguides\u002Fday-to-day\u002Fraise-a-cap","3.guides\u002F1.day-to-day\u002F6.raise-a-cap",{"title":84,"path":85,"stem":86},"Kraft for VS Code","\u002Fguides\u002Fday-to-day\u002Fvscode","3.guides\u002F1.day-to-day\u002F7.vscode",{"title":88,"path":89,"stem":90},"Kraft on a phone","\u002Fguides\u002Fday-to-day\u002Fkraft-on-a-phone","3.guides\u002F1.day-to-day\u002F8.kraft-on-a-phone",{"title":92,"path":93,"stem":94},"Get notified when an item needs you","\u002Fguides\u002Fday-to-day\u002Fnotifications","3.guides\u002F1.day-to-day\u002F9.notifications",false,{"title":97,"path":98,"stem":99,"children":100,"page":95},"Customize and automate","\u002Fguides\u002Fcustomize","3.guides\u002F2.customize",[101,105,109,113],{"title":102,"path":103,"stem":104},"Write your own chain","\u002Fguides\u002Fcustomize\u002Fwrite-your-own-chain","3.guides\u002F2.customize\u002F1.write-your-own-chain",{"title":106,"path":107,"stem":108},"Add a security review or a gate reviewer","\u002Fguides\u002Fcustomize\u002Fadd-review-agents","3.guides\u002F2.customize\u002F2.add-review-agents",{"title":110,"path":111,"stem":112},"Schedule or webhook work","\u002Fguides\u002Fcustomize\u002Fschedule-and-webhook-work","3.guides\u002F2.customize\u002F3.schedule-and-webhook-work",{"title":114,"path":115,"stem":116},"Share chains with add-ons","\u002Fguides\u002Fcustomize\u002Fshare-chains-with-addons","3.guides\u002F2.customize\u002F4.share-chains-with-addons",{"title":118,"path":119,"stem":120,"children":121,"page":95},"Agents and harnesses","\u002Fguides\u002Fharnesses","3.guides\u002F3.harnesses",[122,126,130,134],{"title":123,"path":124,"stem":125},"Switch a task to another harness","\u002Fguides\u002Fharnesses\u002Fswitch-harness","3.guides\u002F3.harnesses\u002F1.switch-harness",{"title":127,"path":128,"stem":129},"Add or override a harness","\u002Fguides\u002Fharnesses\u002Fadding-a-harness","3.guides\u002F3.harnesses\u002F2.adding-a-harness",{"title":131,"path":132,"stem":133},"Build a worker Kit","\u002Fguides\u002Fharnesses\u002Fworker-kit","3.guides\u002F3.harnesses\u002F3.worker-kit",{"title":135,"path":136,"stem":137},"Give a worker its login","\u002Fguides\u002Fharnesses\u002Fgive-a-worker-its-login","3.guides\u002F3.harnesses\u002F4.give-a-worker-its-login",{"title":139,"path":140,"stem":141,"children":142,"page":95},"Run the server","\u002Fguides\u002Frun","3.guides\u002F4.run",[143,147,151,155,159,163,167,171,175,179,183],{"title":144,"path":145,"stem":146},"Remote access","\u002Fguides\u002Frun\u002Fremote-access","3.guides\u002F4.run\u002F01.remote-access",{"title":148,"path":149,"stem":150},"Put a proxy in front of Kraft","\u002Fguides\u002Frun\u002Fput-a-proxy-in-front-of-kraft","3.guides\u002F4.run\u002F02.put-a-proxy-in-front-of-kraft",{"title":152,"path":153,"stem":154},"Restart Kraft without ending running agents","\u002Fguides\u002Frun\u002Frestart-kraft","3.guides\u002F4.run\u002F03.restart-kraft",{"title":156,"path":157,"stem":158},"Back up and restore the database","\u002Fguides\u002Frun\u002Fback-up-and-restore","3.guides\u002F4.run\u002F04.back-up-and-restore",{"title":160,"path":161,"stem":162},"Logs and disk space","\u002Fguides\u002Frun\u002Flogs-and-disk-space","3.guides\u002F4.run\u002F05.logs-and-disk-space",{"title":164,"path":165,"stem":166},"Run Kraft as a service","\u002Fguides\u002Frun\u002Frun-as-a-service","3.guides\u002F4.run\u002F06.run-as-a-service",{"title":168,"path":169,"stem":170},"Upgrade Kraft","\u002Fguides\u002Frun\u002Fupgrade-kraft","3.guides\u002F4.run\u002F07.upgrade-kraft",{"title":172,"path":173,"stem":174},"Upgrade your configuration","\u002Fguides\u002Frun\u002Fupgrade-your-configuration","3.guides\u002F4.run\u002F08.upgrade-your-configuration",{"title":176,"path":177,"stem":178},"Upgrade from 1.4","\u002Fguides\u002Frun\u002Fupgrade-from-1-4","3.guides\u002F4.run\u002F09.upgrade-from-1-4",{"title":180,"path":181,"stem":182},"Upgrade from 0.x or a release candidate","\u002Fguides\u002Frun\u002Fupgrade-from-0-x-or-a-release-candidate","3.guides\u002F4.run\u002F10.upgrade-from-0-x-or-a-release-candidate",{"title":184,"path":185,"stem":186},"Roll back to 1.4","\u002Fguides\u002Frun\u002Froll-back","3.guides\u002F4.run\u002F11.roll-back",{"title":188,"path":189,"stem":190},"Kraft Lite","\u002Fguides\u002Fkraft-lite","3.guides\u002F5.kraft-lite",{"title":192,"path":193,"stem":194,"children":195},"Troubleshooting","\u002Ftroubleshooting","4.troubleshooting",[196,198,202,206,210,214,218],{"title":10,"path":193,"stem":197},"4.troubleshooting\u002Findex",{"title":199,"path":200,"stem":201},"Why did my item stop?","\u002Ftroubleshooting\u002Fwhy-did-my-item-stop","4.troubleshooting\u002F1.why-did-my-item-stop",{"title":203,"path":204,"stem":205},"Stop reasons in detail","\u002Ftroubleshooting\u002Fstop-reasons-in-detail","4.troubleshooting\u002F2.stop-reasons-in-detail",{"title":207,"path":208,"stem":209},"Starting and reaching Kraft","\u002Ftroubleshooting\u002Fstarting-and-reaching-kraft","4.troubleshooting\u002F3.starting-and-reaching-kraft",{"title":211,"path":212,"stem":213},"Doctor failures","\u002Ftroubleshooting\u002Fdoctor-failures","4.troubleshooting\u002F4.doctor-failures",{"title":215,"path":216,"stem":217},"Sandbox and Kit stops","\u002Ftroubleshooting\u002Fsandbox-and-kit-stops","4.troubleshooting\u002F5.sandbox-and-kit-stops",{"title":219,"path":220,"stem":221},"Add-on problems","\u002Ftroubleshooting\u002Faddon-problems","4.troubleshooting\u002F6.addon-problems",{"title":223,"path":224,"stem":225,"children":226},"Reference","\u002Freference","5.reference",[227,229,267,289,293,391,409,435,439,443,477,481],{"title":10,"path":224,"stem":228},"5.reference\u002Findex",{"title":230,"path":231,"stem":232,"children":233},"Web UI","\u002Freference\u002Fweb-ui","5.reference\u002F00.web-ui\u002Findex",[234,235,239,243,247,251,255,259,263],{"title":10,"path":231,"stem":232},{"title":236,"path":237,"stem":238},"Sidebar, search, and keyboard","\u002Freference\u002Fweb-ui\u002Fsidebar-search-and-keyboard","5.reference\u002F00.web-ui\u002F0.sidebar-search-and-keyboard",{"title":240,"path":241,"stem":242},"The board","\u002Freference\u002Fweb-ui\u002Fboard","5.reference\u002F00.web-ui\u002F1.board",{"title":244,"path":245,"stem":246},"An item's page","\u002Freference\u002Fweb-ui\u002Fitem-page","5.reference\u002F00.web-ui\u002F2.item-page",{"title":248,"path":249,"stem":250},"Fix loops and test scopes","\u002Freference\u002Fweb-ui\u002Ffix-loops-and-test-scopes","5.reference\u002F00.web-ui\u002F3.fix-loops-and-test-scopes",{"title":252,"path":253,"stem":254},"Config before an item starts","\u002Freference\u002Fweb-ui\u002Fconfig-before-start","5.reference\u002F00.web-ui\u002F4.config-before-start",{"title":256,"path":257,"stem":258},"The review page","\u002Freference\u002Fweb-ui\u002Freview-page","5.reference\u002F00.web-ui\u002F5.review-page",{"title":260,"path":261,"stem":262},"Templates and Settings","\u002Freference\u002Fweb-ui\u002Ftemplates-and-settings","5.reference\u002F00.web-ui\u002F6.templates-and-settings",{"title":264,"path":265,"stem":266},"Analytics","\u002Freference\u002Fweb-ui\u002Fanalytics","5.reference\u002F00.web-ui\u002F7.analytics",{"title":268,"path":269,"stem":270,"children":271},"CLI","\u002Freference\u002Fcli","5.reference\u002F01.cli\u002Findex",[272,273,277,281,285],{"title":10,"path":269,"stem":270},{"title":274,"path":275,"stem":276},"Item verbs","\u002Freference\u002Fcli\u002Fitem","5.reference\u002F01.cli\u002F2.item",{"title":278,"path":279,"stem":280},"View verbs","\u002Freference\u002Fcli\u002Fview","5.reference\u002F01.cli\u002F3.view",{"title":282,"path":283,"stem":284},"Repo verbs","\u002Freference\u002Fcli\u002Frepo","5.reference\u002F01.cli\u002F4.repo",{"title":286,"path":287,"stem":288},"Admin verbs","\u002Freference\u002Fcli\u002Fadmin","5.reference\u002F01.cli\u002F5.admin",{"title":290,"path":291,"stem":292},"Work item statuses","\u002Freference\u002Fstatuses","5.reference\u002F02.statuses",{"title":294,"path":295,"stem":296,"children":297},"Configuration","\u002Freference\u002Fconfiguration","5.reference\u002F03.configuration\u002Findex",[298,299,317,321,325,329,333,337,341,345,379,383,387],{"title":10,"path":295,"stem":296},{"title":300,"path":301,"stem":302,"children":303},"repos.yaml","\u002Freference\u002Fconfiguration\u002Frepos","5.reference\u002F03.configuration\u002F02.repos\u002Findex",[304,305,309,313],{"title":10,"path":301,"stem":302},{"title":306,"path":307,"stem":308},"How connect proposes commands","\u002Freference\u002Fconfiguration\u002Frepos\u002Fconnect-proposals","5.reference\u002F03.configuration\u002F02.repos\u002F1.connect-proposals",{"title":310,"path":311,"stem":312},"detectors.yaml","\u002Freference\u002Fconfiguration\u002Frepos\u002Fdetectors","5.reference\u002F03.configuration\u002F02.repos\u002F2.detectors",{"title":314,"path":315,"stem":316},"Workspaces","\u002Freference\u002Fconfiguration\u002Frepos\u002Fworkspaces","5.reference\u002F03.configuration\u002F02.repos\u002F3.workspaces",{"title":318,"path":319,"stem":320},"policy.yaml","\u002Freference\u002Fconfiguration\u002Fpolicy","5.reference\u002F03.configuration\u002F03.policy",{"title":322,"path":323,"stem":324},"Library and chains","\u002Freference\u002Fconfiguration\u002Flibrary-and-chains","5.reference\u002F03.configuration\u002F04.library-and-chains",{"title":326,"path":327,"stem":328},"harnesses.yaml","\u002Freference\u002Fconfiguration\u002Fharnesses-file","5.reference\u002F03.configuration\u002F05.harnesses-file",{"title":330,"path":331,"stem":332},"access.yaml","\u002Freference\u002Fconfiguration\u002Faccess","5.reference\u002F03.configuration\u002F06.access",{"title":334,"path":335,"stem":336},"intake.yaml","\u002Freference\u002Fconfiguration\u002Fintake","5.reference\u002F03.configuration\u002F07.intake",{"title":338,"path":339,"stem":340},"notify.yaml","\u002Freference\u002Fconfiguration\u002Fnotify","5.reference\u002F03.configuration\u002F08.notify",{"title":342,"path":343,"stem":344},"theme.yaml","\u002Freference\u002Fconfiguration\u002Ftheme","5.reference\u002F03.configuration\u002F09.theme",{"title":346,"path":347,"stem":348,"children":349},"Sandboxed workers","\u002Freference\u002Fconfiguration\u002Fsandbox","5.reference\u002F03.configuration\u002F10.sandbox\u002Findex",[350,351,355,359,363,367,371,375],{"title":10,"path":347,"stem":348},{"title":352,"path":353,"stem":354},"Resource limits","\u002Freference\u002Fconfiguration\u002Fsandbox\u002Fresource-limits","5.reference\u002F03.configuration\u002F10.sandbox\u002F1.resource-limits",{"title":356,"path":357,"stem":358},"Callbacks from a sandbox","\u002Freference\u002Fconfiguration\u002Fsandbox\u002Fcallbacks","5.reference\u002F03.configuration\u002F10.sandbox\u002F2.callbacks",{"title":360,"path":361,"stem":362},"Network policy","\u002Freference\u002Fconfiguration\u002Fsandbox\u002Fnetwork-policy","5.reference\u002F03.configuration\u002F10.sandbox\u002F3.network-policy",{"title":364,"path":365,"stem":366},"Credentials","\u002Freference\u002Fconfiguration\u002Fsandbox\u002Fcredentials","5.reference\u002F03.configuration\u002F10.sandbox\u002F4.credentials",{"title":368,"path":369,"stem":370},"Kits","\u002Freference\u002Fconfiguration\u002Fsandbox\u002Fkits","5.reference\u002F03.configuration\u002F10.sandbox\u002F5.kits",{"title":372,"path":373,"stem":374},"sandbox.yaml","\u002Freference\u002Fconfiguration\u002Fsandbox\u002Fsandbox-yaml","5.reference\u002F03.configuration\u002F10.sandbox\u002F6.sandbox-yaml",{"title":376,"path":377,"stem":378},"Git in a sandbox","\u002Freference\u002Fconfiguration\u002Fsandbox\u002Fgit-in-a-sandbox","5.reference\u002F03.configuration\u002F10.sandbox\u002F7.git-in-a-sandbox",{"title":380,"path":381,"stem":382},"Environment variables","\u002Freference\u002Fconfiguration\u002Fenvironment-variables","5.reference\u002F03.configuration\u002F11.environment-variables",{"title":384,"path":385,"stem":386},"Add-ons and collections","\u002Freference\u002Fconfiguration\u002Faddons","5.reference\u002F03.configuration\u002F12.addons",{"title":388,"path":389,"stem":390},"Repo libraries","\u002Freference\u002Fconfiguration\u002Frepo-libraries","5.reference\u002F03.configuration\u002F13.repo-libraries",{"title":392,"path":393,"stem":394,"children":395},"Chain file keys","\u002Freference\u002Fchain-nodes","5.reference\u002F04.chain-nodes\u002Findex",[396,397,401,405],{"title":10,"path":393,"stem":394},{"title":398,"path":399,"stem":400},"Subprocess tasks","\u002Freference\u002Fchain-nodes\u002Fsubprocess-tasks","5.reference\u002F04.chain-nodes\u002F2.subprocess-tasks",{"title":402,"path":403,"stem":404},"Fix loop and judge","\u002Freference\u002Fchain-nodes\u002Ffix-loop","5.reference\u002F04.chain-nodes\u002F3.fix-loop",{"title":406,"path":407,"stem":408},"Result file","\u002Freference\u002Fchain-nodes\u002Fresult-file","5.reference\u002F04.chain-nodes\u002F4.result-file",{"title":410,"path":411,"stem":412,"children":413},"Agent harnesses","\u002Freference\u002Fharnesses","5.reference\u002F05.harnesses\u002Findex",[414,415,419,423,427,431],{"title":10,"path":411,"stem":412},{"title":416,"path":417,"stem":418},"Unattended runs","\u002Freference\u002Fharnesses\u002Funattended-runs","5.reference\u002F05.harnesses\u002F2.unattended-runs",{"title":420,"path":421,"stem":422},"Agent profiles","\u002Freference\u002Fharnesses\u002Fagent-profiles","5.reference\u002F05.harnesses\u002F3.agent-profiles",{"title":424,"path":425,"stem":426},"Harness definition files","\u002Freference\u002Fharnesses\u002Fharness-files","5.reference\u002F05.harnesses\u002F4.harness-files",{"title":428,"path":429,"stem":430},"Fallback and escalation","\u002Freference\u002Fharnesses\u002Ffallback-and-escalation","5.reference\u002F05.harnesses\u002F5.fallback-and-escalation",{"title":432,"path":433,"stem":434},"Cost reporting","\u002Freference\u002Fharnesses\u002Fcost-reporting","5.reference\u002F05.harnesses\u002F6.cost-reporting",{"title":436,"path":437,"stem":438},"Permission gate","\u002Freference\u002Fpermissions","5.reference\u002F06.permissions",{"title":440,"path":441,"stem":442},"Inbound triggers","\u002Freference\u002Ftriggers","5.reference\u002F07.triggers",{"title":444,"path":445,"stem":446,"children":447},"HTTP API","\u002Freference\u002Fhttp-api","5.reference\u002F08.http-api\u002Findex",[448,449,453,457,461,465,469,473],{"title":10,"path":445,"stem":446},{"title":450,"path":451,"stem":452},"Filing, reading and changing work items","\u002Freference\u002Fhttp-api\u002Fwork-items","5.reference\u002F08.http-api\u002F2.work-items",{"title":454,"path":455,"stem":456},"Gates, run control, ending and retry","\u002Freference\u002Fhttp-api\u002Fgates-run-control-and-ending","5.reference\u002F08.http-api\u002F3.gates-run-control-and-ending",{"title":458,"path":459,"stem":460},"The work item object","\u002Freference\u002Fhttp-api\u002Fwork-item-object","5.reference\u002F08.http-api\u002F4.work-item-object",{"title":462,"path":463,"stem":464},"Budget, events, diff and documents","\u002Freference\u002Fhttp-api\u002Fbudget-and-events","5.reference\u002F08.http-api\u002F5.budget-and-events",{"title":466,"path":467,"stem":468},"Repos, chains, harnesses and the server","\u002Freference\u002Fhttp-api\u002Frepos-chains-harnesses-and-server","5.reference\u002F08.http-api\u002F6.repos-chains-harnesses-and-server",{"title":470,"path":471,"stem":472},"Drafts","\u002Freference\u002Fhttp-api\u002Fdrafts","5.reference\u002F08.http-api\u002F7.drafts",{"title":474,"path":475,"stem":476},"Ops for each draft area","\u002Freference\u002Fhttp-api\u002Fdraft-ops","5.reference\u002F08.http-api\u002F8.draft-ops",{"title":478,"path":479,"stem":480},"MCP tools","\u002Freference\u002Fmcp-tools","5.reference\u002F09.mcp-tools",{"title":482,"path":483,"stem":484},"Events","\u002Freference\u002Fevents","5.reference\u002F10.events",{"title":486,"path":487,"stem":488,"children":489},"Security and project","\u002Fproject","6.project",[490,492,496,500,504,508,512,516],{"title":10,"path":487,"stem":491},"6.project\u002Findex",{"title":493,"path":494,"stem":495},"Security","\u002Fproject\u002Fsecurity","6.project\u002F1.security",{"title":497,"path":498,"stem":499},"Data and privacy","\u002Fproject\u002Fdata-and-privacy","6.project\u002F2.data-and-privacy",{"title":501,"path":502,"stem":503},"What's new in 2.0","\u002Fproject\u002Fwhats-new","6.project\u002F3.whats-new",{"title":505,"path":506,"stem":507},"Status and support","\u002Fproject\u002Fstatus-and-support","6.project\u002F4.status-and-support",{"title":509,"path":510,"stem":511},"Architecture","\u002Fproject\u002Farchitecture","6.project\u002F5.architecture",{"title":513,"path":514,"stem":515},"Source map","\u002Fproject\u002Fsource-map","6.project\u002F6.source-map",{"title":517,"path":518,"stem":519},"Contributing","\u002Fproject\u002Fcontributing","6.project\u002F7.contributing",{"id":521,"title":156,"body":522,"description":3269,"extension":3270,"links":3271,"meta":3272,"navigation":3273,"path":157,"seo":3274,"stem":158,"__hash__":3275},"docs\u002F3.guides\u002F4.run\u002F04.back-up-and-restore.md",{"type":523,"value":524,"toc":3255},"minimark",[525,529,534,594,598,617,1074,1079,1090,1094,1097,1197,1201,1210,1243,1252,1284,1287,1301,1308,1311,1328,2406,2411,2420,2433,2459,2463,2469,2968,2972,2998,3007,3017,3023,3026,3029,3035,3217,3224,3228,3251],[526,527,528],"p",{},"You will have a private, dated copy of Kraft's database that you have checked,\nand the steps that put it back. Kraft also makes a copy of its own before an\nupgrade migrates the database, and this page says how to find it.",[530,531,533],"h2",{"id":532},"before-you-start","Before you start",[535,536,537,575,587],"ul",{},[538,539,540,544,545,548,549,552,553,556,557,560,561,563,564,567,568,571,572,574],"li",{},[541,542,543],"code",{},"$KRAFT_HOME"," is ",[541,546,547],{},"~\u002F.kraft"," unless you set it; see\n",[550,551,380],"a",{"href":381},". The\ncommands find ",[541,554,555],{},"run\u002F"," as Kraft does, from ",[541,558,559],{},"$KRAFT_RUN_DIR"," when you set it and\nfrom ",[541,562,543],{}," otherwise, and ",[541,565,566],{},"config\u002F"," from ",[541,569,570],{},"$KRAFT_CONFIG_DIR"," or\n",[541,573,543],{},".",[538,576,577,578,581,582,586],{},"The commands use the ",[541,579,580],{},"sqlite3"," command. ",[550,583,585],{"href":584},"#back-up-without-sqlite3","Back up without sqlite3","\nhas a Python form for a machine without it.",[538,588,589,590,574],{},"A backup needs no stop. A restore does: see\n",[550,591,593],{"href":592},"#restore-a-backup","Restore a backup",[530,595,597],{"id":596},"back-up-the-database","Back up the database",[526,599,600,603,604,608,609,612,613,616],{},[541,601,602],{},"run\u002Forchestrator.db"," holds every ",[550,605,607],{"href":606},"\u002Fconcepts\u002Fvocabulary#work-item","work item",", event, session and review\nthread. Kraft runs SQLite in WAL mode, so recent writes can sit in\n",[541,610,611],{},"orchestrator.db-wal"," beside it. A plain copy of ",[541,614,615],{},"orchestrator.db"," while the\nserver runs is not a backup: it can miss them, or not open.",[618,619,620,798],"ol",{},[538,621,622,623,626,629,630,768,779,781,782,785,786,788,789,792,793,795,796,574],{},"Use SQLite's online backup, which is safe while the server runs. The command\nnames the file for the second you run it and prints the name. Write the name\ndown: verify and restore need it, and it is the file to keep. A backup taken at\nanother time never replaces an earlier one, so the copy you took before an\nupgrade is still there after the next one.",[624,625],"br",{},[541,627,628],{},"-readonly"," opens the database you copy from read-only, so a wrong path fails\ninstead of creating an empty database and an empty backup of it:",[631,632,637],"pre",{"className":633,"code":634,"language":635,"meta":636,"style":636},"language-bash shiki shiki-themes github-light-high-contrast github-light-high-contrast github-dark-high-contrast","run=\"${KRAFT_RUN_DIR:-${KRAFT_HOME:-$HOME\u002F.kraft}\u002Frun}\"\nbackup=\"$HOME\u002Fkraft-backup-$(date +%Y%m%d-%H%M%S).db\"\nsqlite3 -readonly \"$run\u002Forchestrator.db\" \".backup '$backup'\" && chmod 600 \"$backup\" && echo \"$backup\"\n","bash","",[541,638,639,691,714],{"__ignoreMap":636},[640,641,644,648,652,656,659,662,665,668,670,673,676,678,681,684,686,688],"span",{"class":642,"line":643},"line",1,[640,645,647],{"class":646},"s7iLA","run",[640,649,651],{"class":650},"sklAV","=",[640,653,655],{"class":654},"semJd","\"${",[640,657,658],{"class":646},"KRAFT_RUN_DIR",[640,660,661],{"class":650},":-",[640,663,664],{"class":654},"${",[640,666,667],{"class":646},"KRAFT_HOME",[640,669,661],{"class":650},[640,671,672],{"class":646},"$HOME",[640,674,675],{"class":650},"\u002F",[640,677,574],{"class":654},[640,679,680],{"class":646},"kraft",[640,682,683],{"class":654},"}",[640,685,675],{"class":650},[640,687,647],{"class":646},[640,689,690],{"class":654},"}\"\n",[640,692,694,697,699,702,704,707,711],{"class":642,"line":693},2,[640,695,696],{"class":646},"backup",[640,698,651],{"class":650},[640,700,701],{"class":654},"\"",[640,703,672],{"class":646},[640,705,706],{"class":654},"\u002Fkraft-backup-$(",[640,708,710],{"class":709},"szw1H","date",[640,712,713],{"class":654}," +%Y%m%d-%H%M%S).db\"\n",[640,715,717,719,723,726,729,732,735,738,741,744,747,750,752,754,756,758,761,763,765],{"class":642,"line":716},3,[640,718,580],{"class":709},[640,720,722],{"class":721},"ssYy9"," -readonly",[640,724,725],{"class":654}," \"",[640,727,728],{"class":646},"$run",[640,730,731],{"class":654},"\u002Forchestrator.db\"",[640,733,734],{"class":654}," \".backup '",[640,736,737],{"class":646},"$backup",[640,739,740],{"class":654},"'\"",[640,742,743],{"class":646}," && ",[640,745,746],{"class":709},"chmod",[640,748,749],{"class":721}," 600",[640,751,725],{"class":654},[640,753,737],{"class":646},[640,755,701],{"class":654},[640,757,743],{"class":646},[640,759,760],{"class":721},"echo",[640,762,725],{"class":654},[640,764,737],{"class":646},[640,766,767],{"class":654},"\"\n",[631,769,774],{"className":770,"code":772,"language":773,"meta":636},[771],"language-text","\u002Fhome\u002Fyou\u002Fkraft-backup-20261002-093015.db\n","text",[541,775,776],{"__ignoreMap":636},[640,777,772],{"className":778},[642],[624,780],{},"The backup holds everything the database holds, and ",[541,783,784],{},".backup"," makes it\nreadable by other accounts under the usual umask. The ",[541,787,746],{}," keeps it at\n",[541,790,791],{},"600",", like the database. With no ",[541,794,580],{}," command, use\n",[550,797,585],{"href":584},[538,799,800,801,803,804,807,808,810,811,813,814,816,817,819,820,823,824,826,828,829,803,832,835,836,840,841,844,845,847,848,851,852,854,857,858,861,862,865,866,869,870,873,874,877,878,880,881,884,885,1053,1062,1064,1068,1069,803,1071,1073],{},"Copy ",[541,802,566],{}," and ",[541,805,806],{},"run\u002Fattachments\u002F"," too. A database restore brings back\nneither. Copy ",[541,809,566],{}," whole: ",[541,812,330],{}," holds your password hash,\n",[541,815,338],{}," a webhook URL, and ",[541,818,300],{}," any ",[541,821,822],{},"env:"," values, so the copy\nstays private.",[624,825],{},[541,827,566],{}," also holds ",[541,830,831],{},"addons.yaml",[541,833,834],{},"addons.lock",", which are all a\nbackup needs of your installed\n",[550,837,839],{"href":838},"\u002Fconcepts\u002Fvocabulary#add-on","Kraft add-ons"," from git collections.\n",[541,842,843],{},"run\u002Faddons\u002F"," needs no copy. An add-on from a directory collection comes\nback only while that directory still holds the same files.",[624,846],{},"The folder is named for the second you run the command, and ",[541,849,850],{},"mkdir"," stops the\ncommand if the name is already there, so an earlier copy is never overwritten.\nWrite down the name it prints: the restore needs it.",[624,853],{},[541,855,856],{},"config"," follows ",[541,859,860],{},"KRAFT_CONFIG_DIR",", then ",[541,863,864],{},"KRAFT_TEMPLATES_DIR",", when you set\none. A 1.4 home that no 2.0 start has renamed keeps its configuration in\n",[541,867,868],{},"templates\u002F",": put that folder in the ",[541,871,872],{},"config="," line. ",[541,875,876],{},"cp -RH"," follows a\n",[541,879,856],{}," or ",[541,882,883],{},"attachments"," that is a symbolic link, so the copy holds the files,\nnot a link that dangles without the original:",[631,886,888],{"className":633,"code":887,"language":635,"meta":636,"style":636},"run=\"${KRAFT_RUN_DIR:-${KRAFT_HOME:-$HOME\u002F.kraft}\u002Frun}\"\nconfig=\"${KRAFT_CONFIG_DIR:-${KRAFT_TEMPLATES_DIR:-${KRAFT_HOME:-$HOME\u002F.kraft}\u002Fconfig}}\"\nfiles=\"$HOME\u002Fkraft-files-$(date +%Y%m%d-%H%M%S)\"\nmkdir -m 700 \"$files\" && cp -RH \"$config\" \"$files\u002Fconfig\" && cp -RH \"$run\u002Fattachments\" \"$files\u002Fattachments\" && echo \"$files\"\n",[541,889,890,924,965,984],{"__ignoreMap":636},[640,891,892,894,896,898,900,902,904,906,908,910,912,914,916,918,920,922],{"class":642,"line":643},[640,893,647],{"class":646},[640,895,651],{"class":650},[640,897,655],{"class":654},[640,899,658],{"class":646},[640,901,661],{"class":650},[640,903,664],{"class":654},[640,905,667],{"class":646},[640,907,661],{"class":650},[640,909,672],{"class":646},[640,911,675],{"class":650},[640,913,574],{"class":654},[640,915,680],{"class":646},[640,917,683],{"class":654},[640,919,675],{"class":650},[640,921,647],{"class":646},[640,923,690],{"class":654},[640,925,926,928,930,932,934,936,938,940,942,944,946,948,950,952,954,956,958,960,962],{"class":642,"line":693},[640,927,856],{"class":646},[640,929,651],{"class":650},[640,931,655],{"class":654},[640,933,860],{"class":646},[640,935,661],{"class":650},[640,937,664],{"class":654},[640,939,864],{"class":646},[640,941,661],{"class":650},[640,943,664],{"class":654},[640,945,667],{"class":646},[640,947,661],{"class":650},[640,949,672],{"class":646},[640,951,675],{"class":650},[640,953,574],{"class":654},[640,955,680],{"class":646},[640,957,683],{"class":654},[640,959,675],{"class":650},[640,961,856],{"class":646},[640,963,964],{"class":654},"}}\"\n",[640,966,967,970,972,974,976,979,981],{"class":642,"line":716},[640,968,969],{"class":646},"files",[640,971,651],{"class":650},[640,973,701],{"class":654},[640,975,672],{"class":646},[640,977,978],{"class":654},"\u002Fkraft-files-$(",[640,980,710],{"class":709},[640,982,983],{"class":654}," +%Y%m%d-%H%M%S)\"\n",[640,985,987,989,992,995,997,1000,1002,1004,1007,1010,1012,1015,1017,1019,1021,1024,1026,1028,1030,1032,1034,1037,1039,1041,1043,1045,1047,1049,1051],{"class":642,"line":986},4,[640,988,850],{"class":709},[640,990,991],{"class":721}," -m",[640,993,994],{"class":721}," 700",[640,996,725],{"class":654},[640,998,999],{"class":646},"$files",[640,1001,701],{"class":654},[640,1003,743],{"class":646},[640,1005,1006],{"class":709},"cp",[640,1008,1009],{"class":721}," -RH",[640,1011,725],{"class":654},[640,1013,1014],{"class":646},"$config",[640,1016,701],{"class":654},[640,1018,725],{"class":654},[640,1020,999],{"class":646},[640,1022,1023],{"class":654},"\u002Fconfig\"",[640,1025,743],{"class":646},[640,1027,1006],{"class":709},[640,1029,1009],{"class":721},[640,1031,725],{"class":654},[640,1033,728],{"class":646},[640,1035,1036],{"class":654},"\u002Fattachments\"",[640,1038,725],{"class":654},[640,1040,999],{"class":646},[640,1042,1036],{"class":654},[640,1044,743],{"class":646},[640,1046,760],{"class":721},[640,1048,725],{"class":654},[640,1050,999],{"class":646},[640,1052,767],{"class":654},[631,1054,1057],{"className":1055,"code":1056,"language":773,"meta":636},[771],"\u002Fhome\u002Fyou\u002Fkraft-files-20261002-093015\n",[541,1058,1059],{"__ignoreMap":636},[640,1060,1056],{"className":1061},[642],[624,1063],{},[550,1065,1067],{"href":1066},"\u002Fguides\u002Frun\u002Fupgrade-your-configuration#keep-your-config-in-git","Keep your configuration in git","\nleaves ",[541,1070,330],{},[541,1072,338],{}," out on purpose, so a git copy alone is\nnot a complete backup.",[526,1075,1076,1078],{},[541,1077,806],{}," holds the spec and plan copy of each item filed with one.\nAfter a restore, an item that has not started needs its copy: without it the\nitem stops when its worktree is made, and the message names the missing file.",[526,1080,1081,1082,1085,1086,1089],{},"You do not need to back up ",[541,1083,1084],{},"run\u002Findex.db",". It is the search index, and\n",[541,1087,1088],{},"kraft admin reindex"," rebuilds it.",[1091,1092,585],"h3",{"id":1093},"back-up-without-sqlite3",[526,1095,1096],{},"Python does the same as step 1, and prints the same name:",[631,1098,1100],{"className":633,"code":1099,"language":635,"meta":636,"style":636},"run=\"${KRAFT_RUN_DIR:-${KRAFT_HOME:-$HOME\u002F.kraft}\u002Frun}\"\nbackup=\"$HOME\u002Fkraft-backup-$(date +%Y%m%d-%H%M%S).db\"\npython3 -c \"import sqlite3, sys; sqlite3.connect('file:' + sys.argv[1] + '?mode=ro', uri=True).backup(sqlite3.connect(sys.argv[2]))\" \"$run\u002Forchestrator.db\" \"$backup\" && chmod 600 \"$backup\" && echo \"$backup\"\n",[541,1101,1102,1136,1152],{"__ignoreMap":636},[640,1103,1104,1106,1108,1110,1112,1114,1116,1118,1120,1122,1124,1126,1128,1130,1132,1134],{"class":642,"line":643},[640,1105,647],{"class":646},[640,1107,651],{"class":650},[640,1109,655],{"class":654},[640,1111,658],{"class":646},[640,1113,661],{"class":650},[640,1115,664],{"class":654},[640,1117,667],{"class":646},[640,1119,661],{"class":650},[640,1121,672],{"class":646},[640,1123,675],{"class":650},[640,1125,574],{"class":654},[640,1127,680],{"class":646},[640,1129,683],{"class":654},[640,1131,675],{"class":650},[640,1133,647],{"class":646},[640,1135,690],{"class":654},[640,1137,1138,1140,1142,1144,1146,1148,1150],{"class":642,"line":693},[640,1139,696],{"class":646},[640,1141,651],{"class":650},[640,1143,701],{"class":654},[640,1145,672],{"class":646},[640,1147,706],{"class":654},[640,1149,710],{"class":709},[640,1151,713],{"class":654},[640,1153,1154,1157,1160,1163,1165,1167,1169,1171,1173,1175,1177,1179,1181,1183,1185,1187,1189,1191,1193,1195],{"class":642,"line":716},[640,1155,1156],{"class":709},"python3",[640,1158,1159],{"class":721}," -c",[640,1161,1162],{"class":654}," \"import sqlite3, sys; sqlite3.connect('file:' + sys.argv[1] + '?mode=ro', uri=True).backup(sqlite3.connect(sys.argv[2]))\"",[640,1164,725],{"class":654},[640,1166,728],{"class":646},[640,1168,731],{"class":654},[640,1170,725],{"class":654},[640,1172,737],{"class":646},[640,1174,701],{"class":654},[640,1176,743],{"class":646},[640,1178,746],{"class":709},[640,1180,749],{"class":721},[640,1182,725],{"class":654},[640,1184,737],{"class":646},[640,1186,701],{"class":654},[640,1188,743],{"class":646},[640,1190,760],{"class":721},[640,1192,725],{"class":654},[640,1194,737],{"class":646},[640,1196,767],{"class":654},[530,1198,1200],{"id":1199},"verify-the-backup","Verify the backup",[526,1202,1203,1204,1206,1207,1209],{},"Open the copy and count its work items. Set ",[541,1205,696],{}," to the file your backup step\nprinted, so the block works in a new terminal. ",[541,1208,628],{}," makes a wrong name\nfail instead of creating an empty file:",[631,1211,1213],{"className":633,"code":1212,"language":635,"meta":636,"style":636},"backup=\"$HOME\u002Fkraft-backup-20261002-093015.db\"\nsqlite3 -readonly \"$backup\" \"PRAGMA integrity_check; SELECT count(*) FROM work_items;\"\n",[541,1214,1215,1228],{"__ignoreMap":636},[640,1216,1217,1219,1221,1223,1225],{"class":642,"line":643},[640,1218,696],{"class":646},[640,1220,651],{"class":650},[640,1222,701],{"class":654},[640,1224,672],{"class":646},[640,1226,1227],{"class":654},"\u002Fkraft-backup-20261002-093015.db\"\n",[640,1229,1230,1232,1234,1236,1238,1240],{"class":642,"line":693},[640,1231,580],{"class":709},[640,1233,722],{"class":721},[640,1235,725],{"class":654},[640,1237,737],{"class":646},[640,1239,701],{"class":654},[640,1241,1242],{"class":654}," \"PRAGMA integrity_check; SELECT count(*) FROM work_items;\"\n",[526,1244,1245,1246,1248,1249,1251],{},"Without the ",[541,1247,580],{}," command, set ",[541,1250,696],{}," the same way:",[631,1253,1255],{"className":633,"code":1254,"language":635,"meta":636,"style":636},"backup=\"$HOME\u002Fkraft-backup-20261002-093015.db\"\npython3 -c \"import sqlite3, sys; db = sqlite3.connect('file:' + sys.argv[1] + '?mode=ro', uri=True); print(db.execute('PRAGMA integrity_check').fetchone()[0]); print(db.execute('SELECT count(*) FROM work_items').fetchone()[0])\" \"$backup\"\n",[541,1256,1257,1269],{"__ignoreMap":636},[640,1258,1259,1261,1263,1265,1267],{"class":642,"line":643},[640,1260,696],{"class":646},[640,1262,651],{"class":650},[640,1264,701],{"class":654},[640,1266,672],{"class":646},[640,1268,1227],{"class":654},[640,1270,1271,1273,1275,1278,1280,1282],{"class":642,"line":693},[640,1272,1156],{"class":709},[640,1274,1159],{"class":721},[640,1276,1277],{"class":654}," \"import sqlite3, sys; db = sqlite3.connect('file:' + sys.argv[1] + '?mode=ro', uri=True); print(db.execute('PRAGMA integrity_check').fetchone()[0]); print(db.execute('SELECT count(*) FROM work_items').fetchone()[0])\"",[640,1279,725],{"class":654},[640,1281,737],{"class":646},[640,1283,767],{"class":654},[526,1285,1286],{},"Both print two lines:",[631,1288,1291],{"className":1289,"code":1290,"language":773,"meta":636},[771],"ok\n42\n",[541,1292,1293,1297],{"__ignoreMap":636},[640,1294,1296],{"className":1295},[642],"ok\n",[640,1298,1300],{"className":1299},[642],"42\n",[526,1302,1303,1304,1307],{},"You know it worked when the first line is ",[541,1305,1306],{},"ok"," and the second is the number of\nwork items you expect.",[530,1309,593],{"id":1310},"restore-a-backup",[526,1312,1313,1314,857,1316,861,1318,1320,1321,1323,1324,1327],{},"A restore replaces the database, so everything done since the backup is lost.\nDo the steps in order. Each block sets the shell variables it uses, so each\nworks in a new terminal, and ",[541,1315,647],{},[541,1317,559],{},[541,1319,543],{},".\nEach block that changes files in ",[541,1322,555],{}," refuses to run while ",[541,1325,1326],{},"kraft.pid"," is\nthere, and says to stop Kraft first.",[618,1329,1330,1375,1640,1909,2391],{},[538,1331,1332,1333,1336,1337,1341,1342,1346,1347,1350,1351,1353,1354,1357,1358,1360,1361,1363,1364,571,1367,1370,1371,1374],{},"Stop the server with ",[541,1334,1335],{},"kraft admin stop",". If Kraft runs as a\n",[550,1338,1340],{"href":1339},"\u002Fguides\u002Frun\u002Frun-as-a-service#run-kraft-as-a-service","service",", read the\nwarning in ",[550,1343,1345],{"href":1344},"\u002Fguides\u002Frun\u002Frun-as-a-service#stop-a-service","Stop a service","\nfirst, run ",[541,1348,1349],{},"kraft admin uninstall-service",", then run ",[541,1352,1335],{},"\nanyway: ",[541,1355,1356],{},"uninstall-service"," does not wait for the server, which can take up\nto 10 seconds to finish and still holds the database until it does.",[624,1359],{},"Go on only when ",[541,1362,1335],{}," prints ",[541,1365,1366],{},"kraft: stopped (pid N)",[541,1368,1369],{},"kraft: no server running",". If it prints ",[541,1372,1373],{},"kraft: pid N did not stop within 15s","\nand exits 1, the server is still running: do not touch the database.",[538,1376,1377,1378,1380,1381,1384,1385,1599,1601,1602,1604,1605,1607,1608,1610,1611,1614,1615,1617,1618,1620,1621,1623,1624,1627,1628,1630,1631,1633,1634,1636,1637,1639],{},"Move the current database aside, with the files SQLite keeps beside it. Kraft\nruns SQLite in WAL mode, and ",[541,1379,611],{}," holds writes that belong to\nthe file it sits beside, so the three move together and none stays behind for\nthe restored database to meet. The directory name carries the time, so a\nsecond restore never touches the first one's copy, and ",[541,1382,1383],{},"mv -n"," never\noverwrites:",[631,1386,1388],{"className":633,"code":1387,"language":635,"meta":636,"style":636},"run=\"${KRAFT_RUN_DIR:-${KRAFT_HOME:-$HOME\u002F.kraft}\u002Frun}\"\nsafe=\"$run\u002Fbefore-restore-$(date +%Y%m%d-%H%M%S)\"\nif [ -e \"$run\u002Fkraft.pid\" ]; then\n  echo \"$run\u002Fkraft.pid exists: a server may be running. If a service runs Kraft, follow Stop a service on the Run Kraft as a service page. Otherwise run kraft admin stop, which also clears a stale pid file.\"\nelse\n  mkdir \"$safe\" && for f in orchestrator.db orchestrator.db-wal orchestrator.db-shm; do\n    if [ -e \"$run\u002F$f\" ]; then mv -n \"$run\u002F$f\" \"$safe\"\u002F; fi\n  done && ls \"$safe\"\nfi\n",[541,1389,1390,1424,1442,1466,1478,1484,1523,1577,1594],{"__ignoreMap":636},[640,1391,1392,1394,1396,1398,1400,1402,1404,1406,1408,1410,1412,1414,1416,1418,1420,1422],{"class":642,"line":643},[640,1393,647],{"class":646},[640,1395,651],{"class":650},[640,1397,655],{"class":654},[640,1399,658],{"class":646},[640,1401,661],{"class":650},[640,1403,664],{"class":654},[640,1405,667],{"class":646},[640,1407,661],{"class":650},[640,1409,672],{"class":646},[640,1411,675],{"class":650},[640,1413,574],{"class":654},[640,1415,680],{"class":646},[640,1417,683],{"class":654},[640,1419,675],{"class":650},[640,1421,647],{"class":646},[640,1423,690],{"class":654},[640,1425,1426,1429,1431,1433,1435,1438,1440],{"class":642,"line":693},[640,1427,1428],{"class":646},"safe",[640,1430,651],{"class":650},[640,1432,701],{"class":654},[640,1434,728],{"class":646},[640,1436,1437],{"class":654},"\u002Fbefore-restore-$(",[640,1439,710],{"class":709},[640,1441,983],{"class":654},[640,1443,1444,1447,1450,1453,1455,1457,1460,1463],{"class":642,"line":716},[640,1445,1446],{"class":650},"if",[640,1448,1449],{"class":646}," [ ",[640,1451,1452],{"class":650},"-e",[640,1454,725],{"class":654},[640,1456,728],{"class":646},[640,1458,1459],{"class":654},"\u002Fkraft.pid\"",[640,1461,1462],{"class":646}," ]; ",[640,1464,1465],{"class":650},"then\n",[640,1467,1468,1471,1473,1475],{"class":642,"line":986},[640,1469,1470],{"class":721},"  echo",[640,1472,725],{"class":654},[640,1474,728],{"class":646},[640,1476,1477],{"class":654},"\u002Fkraft.pid exists: a server may be running. If a service runs Kraft, follow Stop a service on the Run Kraft as a service page. Otherwise run kraft admin stop, which also clears a stale pid file.\"\n",[640,1479,1481],{"class":642,"line":1480},5,[640,1482,1483],{"class":650},"else\n",[640,1485,1487,1490,1492,1495,1497,1499,1502,1505,1508,1511,1514,1517,1520],{"class":642,"line":1486},6,[640,1488,1489],{"class":709},"  mkdir",[640,1491,725],{"class":654},[640,1493,1494],{"class":646},"$safe",[640,1496,701],{"class":654},[640,1498,743],{"class":646},[640,1500,1501],{"class":650},"for",[640,1503,1504],{"class":646}," f ",[640,1506,1507],{"class":650},"in",[640,1509,1510],{"class":654}," orchestrator.db",[640,1512,1513],{"class":654}," orchestrator.db-wal",[640,1515,1516],{"class":654}," orchestrator.db-shm",[640,1518,1519],{"class":646},"; ",[640,1521,1522],{"class":650},"do\n",[640,1524,1526,1529,1531,1533,1535,1537,1539,1542,1544,1546,1549,1552,1555,1557,1559,1561,1563,1565,1567,1569,1572,1574],{"class":642,"line":1525},7,[640,1527,1528],{"class":650},"    if",[640,1530,1449],{"class":646},[640,1532,1452],{"class":650},[640,1534,725],{"class":654},[640,1536,728],{"class":646},[640,1538,675],{"class":654},[640,1540,1541],{"class":646},"$f",[640,1543,701],{"class":654},[640,1545,1462],{"class":646},[640,1547,1548],{"class":650},"then",[640,1550,1551],{"class":709}," mv",[640,1553,1554],{"class":721}," -n",[640,1556,725],{"class":654},[640,1558,728],{"class":646},[640,1560,675],{"class":654},[640,1562,1541],{"class":646},[640,1564,701],{"class":654},[640,1566,725],{"class":654},[640,1568,1494],{"class":646},[640,1570,1571],{"class":654},"\"\u002F",[640,1573,1519],{"class":646},[640,1575,1576],{"class":650},"fi\n",[640,1578,1580,1583,1585,1588,1590,1592],{"class":642,"line":1579},8,[640,1581,1582],{"class":650},"  done",[640,1584,743],{"class":646},[640,1586,1587],{"class":709},"ls",[640,1589,725],{"class":654},[640,1591,1494],{"class":646},[640,1593,767],{"class":654},[640,1595,1597],{"class":642,"line":1596},9,[640,1598,1576],{"class":650},[624,1600],{},"The ",[541,1603,1587],{}," lists ",[541,1606,615],{},", and ",[541,1609,611],{}," and\n",[541,1612,1613],{},"orchestrator.db-shm"," when the server left them. If ",[541,1616,850],{}," reports an error,\nor ",[541,1619,1587],{}," lists nothing, stop: nothing was moved, or the database was not where\nthis command looked. A message about ",[541,1622,1326],{}," means nothing was moved: stop\nKraft, then run the block again. Run twice, this step leaves an empty\n",[541,1625,1626],{},"before-restore-*"," folder: the one that holds ",[541,1629,615],{}," is the one that\nmatters.",[624,1632],{},"Delete the ",[541,1635,1626],{}," folder that holds ",[541,1638,615],{}," once you have\nchecked the restored database and no longer need what the old one held. Until\nthen it is the only copy of that work.",[538,1641,1642,1643,1645,1646,1649,1650,1652,1653,574,1657,1659,1660,1662,1663,880,1665,1667,1668,1670,1671,1899,1901,1902,1905,1906,1908],{},"Put the backup in place as ",[541,1644,615],{},", readable by you alone (",[541,1647,1648],{},"0600",",\nas Kraft makes it). Set ",[541,1651,696],{}," to the path of the file your backup step\nprinted, or of the copy you chose in\n",[550,1654,1656],{"href":1655},"#find-the-copy-to-restore","Find the copy to restore",[624,1658],{},"The block refuses to run while a server may be running, or while\n",[541,1661,615],{},", ",[541,1664,611],{},[541,1666,1613],{}," is in ",[541,1669,555],{},".\nSo a second run cannot replace a database Kraft has written since, or put the\nbackup beside a leftover WAL file that SQLite would replay into it:",[631,1672,1674],{"className":633,"code":1673,"language":635,"meta":636,"style":636},"backup=\"$HOME\u002Fkraft-backup-20261002-093015.db\"\nrun=\"${KRAFT_RUN_DIR:-${KRAFT_HOME:-$HOME\u002F.kraft}\u002Frun}\"\nif [ -e \"$run\u002Fkraft.pid\" ]; then\n  echo \"$run\u002Fkraft.pid exists: a server may be running. If a service runs Kraft, follow Stop a service on the Run Kraft as a service page. Otherwise run kraft admin stop, which also clears a stale pid file.\"\nelif [ -e \"$run\u002Forchestrator.db\" ] || [ -e \"$run\u002Forchestrator.db-wal\" ] || [ -e \"$run\u002Forchestrator.db-shm\" ]; then\n  echo \"a database file is already in $run: move the old database aside first, unless the backup is already in place\"\nelif [ ! -f \"$backup\" ]; then\n  echo \"$backup is not a file: set backup to the file your backup step printed\"\nelse\n  cp \"$backup\" \"$run\u002Forchestrator.db\" && chmod 600 \"$run\u002Forchestrator.db\" && ls -l \"$run\u002Forchestrator.db\"\nfi\n",[541,1675,1676,1688,1722,1740,1750,1801,1813,1835,1846,1850,1894],{"__ignoreMap":636},[640,1677,1678,1680,1682,1684,1686],{"class":642,"line":643},[640,1679,696],{"class":646},[640,1681,651],{"class":650},[640,1683,701],{"class":654},[640,1685,672],{"class":646},[640,1687,1227],{"class":654},[640,1689,1690,1692,1694,1696,1698,1700,1702,1704,1706,1708,1710,1712,1714,1716,1718,1720],{"class":642,"line":693},[640,1691,647],{"class":646},[640,1693,651],{"class":650},[640,1695,655],{"class":654},[640,1697,658],{"class":646},[640,1699,661],{"class":650},[640,1701,664],{"class":654},[640,1703,667],{"class":646},[640,1705,661],{"class":650},[640,1707,672],{"class":646},[640,1709,675],{"class":650},[640,1711,574],{"class":654},[640,1713,680],{"class":646},[640,1715,683],{"class":654},[640,1717,675],{"class":650},[640,1719,647],{"class":646},[640,1721,690],{"class":654},[640,1723,1724,1726,1728,1730,1732,1734,1736,1738],{"class":642,"line":716},[640,1725,1446],{"class":650},[640,1727,1449],{"class":646},[640,1729,1452],{"class":650},[640,1731,725],{"class":654},[640,1733,728],{"class":646},[640,1735,1459],{"class":654},[640,1737,1462],{"class":646},[640,1739,1465],{"class":650},[640,1741,1742,1744,1746,1748],{"class":642,"line":986},[640,1743,1470],{"class":721},[640,1745,725],{"class":654},[640,1747,728],{"class":646},[640,1749,1477],{"class":654},[640,1751,1752,1755,1757,1759,1761,1763,1765,1768,1771,1773,1775,1777,1779,1782,1784,1786,1788,1790,1792,1794,1797,1799],{"class":642,"line":1480},[640,1753,1754],{"class":650},"elif",[640,1756,1449],{"class":646},[640,1758,1452],{"class":650},[640,1760,725],{"class":654},[640,1762,728],{"class":646},[640,1764,731],{"class":654},[640,1766,1767],{"class":646}," ] ",[640,1769,1770],{"class":650},"||",[640,1772,1449],{"class":646},[640,1774,1452],{"class":650},[640,1776,725],{"class":654},[640,1778,728],{"class":646},[640,1780,1781],{"class":654},"\u002Forchestrator.db-wal\"",[640,1783,1767],{"class":646},[640,1785,1770],{"class":650},[640,1787,1449],{"class":646},[640,1789,1452],{"class":650},[640,1791,725],{"class":654},[640,1793,728],{"class":646},[640,1795,1796],{"class":654},"\u002Forchestrator.db-shm\"",[640,1798,1462],{"class":646},[640,1800,1465],{"class":650},[640,1802,1803,1805,1808,1810],{"class":642,"line":1486},[640,1804,1470],{"class":721},[640,1806,1807],{"class":654}," \"a database file is already in ",[640,1809,728],{"class":646},[640,1811,1812],{"class":654},": move the old database aside first, unless the backup is already in place\"\n",[640,1814,1815,1817,1819,1822,1825,1827,1829,1831,1833],{"class":642,"line":1525},[640,1816,1754],{"class":650},[640,1818,1449],{"class":646},[640,1820,1821],{"class":650},"!",[640,1823,1824],{"class":650}," -f",[640,1826,725],{"class":654},[640,1828,737],{"class":646},[640,1830,701],{"class":654},[640,1832,1462],{"class":646},[640,1834,1465],{"class":650},[640,1836,1837,1839,1841,1843],{"class":642,"line":1579},[640,1838,1470],{"class":721},[640,1840,725],{"class":654},[640,1842,737],{"class":646},[640,1844,1845],{"class":654}," is not a file: set backup to the file your backup step printed\"\n",[640,1847,1848],{"class":642,"line":1596},[640,1849,1483],{"class":650},[640,1851,1853,1856,1858,1860,1862,1864,1866,1868,1870,1872,1874,1876,1878,1880,1882,1884,1887,1889,1891],{"class":642,"line":1852},10,[640,1854,1855],{"class":709},"  cp",[640,1857,725],{"class":654},[640,1859,737],{"class":646},[640,1861,701],{"class":654},[640,1863,725],{"class":654},[640,1865,728],{"class":646},[640,1867,731],{"class":654},[640,1869,743],{"class":646},[640,1871,746],{"class":709},[640,1873,749],{"class":721},[640,1875,725],{"class":654},[640,1877,728],{"class":646},[640,1879,731],{"class":654},[640,1881,743],{"class":646},[640,1883,1587],{"class":709},[640,1885,1886],{"class":721}," -l",[640,1888,725],{"class":654},[640,1890,728],{"class":646},[640,1892,1893],{"class":654},"\u002Forchestrator.db\"\n",[640,1895,1897],{"class":642,"line":1896},11,[640,1898,1576],{"class":650},[624,1900],{},"When it works it prints one line for the restored file, which starts with\n",[541,1903,1904],{},"-rw-------",". If a message appears, nothing was copied: act on it and run the\nblock again. If ",[541,1907,1006],{}," prints an error, do not start Kraft: it\nwould create an empty database and show an empty board. Move the half-written\ncopy aside as step 2 does, then run this block again.",[538,1910,1911,1912,803,1914,1916,1917,1919,1920,1922,1923,1926,1927,1929,1930,1932,1933,857,1935,861,1937,1940,1941,2372,2374,2375,2377,2378,2380,2381,2383,2386,2387,2390],{},"Put ",[541,1913,566],{},[541,1915,806],{}," back, if you lost them or they are\nwrong. Do it while the server is still stopped from step 1. A database\nrestore does not touch them.",[624,1918],{},"The block overwrites each file of the same name in ",[541,1921,566],{}," with the copy from\nstep 2 of ",[550,1924,597],{"href":1925},"#back-up-the-database",", so it first copies the\n",[541,1928,566],{}," you have to a dated folder beside it and prints the name. It stops,\nrestoring nothing, if that copy cannot be made. Set ",[541,1931,969],{}," to the folder that\nstep printed. ",[541,1934,856],{},[541,1936,570],{},[541,1938,1939],{},"$KRAFT_TEMPLATES_DIR",":",[631,1942,1944],{"className":633,"code":1943,"language":635,"meta":636,"style":636},"files=\"$HOME\u002Fkraft-files-20261002-093015\"\nrun=\"${KRAFT_RUN_DIR:-${KRAFT_HOME:-$HOME\u002F.kraft}\u002Frun}\"\nconfig=\"${KRAFT_CONFIG_DIR:-${KRAFT_TEMPLATES_DIR:-${KRAFT_HOME:-$HOME\u002F.kraft}\u002Fconfig}}\"\nconfig=\"${config%\u002F}\"\nsaved=\"$config.before-restore-$(date +%Y%m%d-%H%M%S)\"\nif [ -e \"$run\u002Fkraft.pid\" ]; then\n  echo \"$run\u002Fkraft.pid exists: a server may be running. If a service runs Kraft, follow Stop a service on the Run Kraft as a service page. Otherwise run kraft admin stop, which also clears a stale pid file.\"\nelif [ ! -d \"$files\u002Fconfig\" ]; then\n  echo \"$files\u002Fconfig is not a folder: set files to the folder your files copy printed\"\nelif [ -e \"$saved\" ]; then\n  echo \"$saved is already there: run this again\"\nelif [ -d \"$config\" ] && ! cp -RH \"$config\" \"$saved\"; then\n  echo \"could not copy $config to $saved: nothing was restored. Delete $saved if it is there, fix the cause, and run this again\"\nelse\n  if [ -d \"$saved\" ]; then echo \"the config you had is kept at $saved\"; fi &&\n    mkdir -p \"$config\" \"$run\u002Fattachments\" &&\n    cp -R \"$files\u002Fconfig\u002F.\" \"$config\u002F\" &&\n    if [ -d \"$files\u002Fattachments\" ]; then cp -R \"$files\u002Fattachments\u002F.\" \"$run\u002Fattachments\u002F\"; fi &&\n    ls \"$config\"\nfi\n",[541,1945,1946,1959,1993,2033,2048,2066,2084,2094,2115,2126,2145,2156,2198,2221,2226,2264,2287,2312,2355,2367],{"__ignoreMap":636},[640,1947,1948,1950,1952,1954,1956],{"class":642,"line":643},[640,1949,969],{"class":646},[640,1951,651],{"class":650},[640,1953,701],{"class":654},[640,1955,672],{"class":646},[640,1957,1958],{"class":654},"\u002Fkraft-files-20261002-093015\"\n",[640,1960,1961,1963,1965,1967,1969,1971,1973,1975,1977,1979,1981,1983,1985,1987,1989,1991],{"class":642,"line":693},[640,1962,647],{"class":646},[640,1964,651],{"class":650},[640,1966,655],{"class":654},[640,1968,658],{"class":646},[640,1970,661],{"class":650},[640,1972,664],{"class":654},[640,1974,667],{"class":646},[640,1976,661],{"class":650},[640,1978,672],{"class":646},[640,1980,675],{"class":650},[640,1982,574],{"class":654},[640,1984,680],{"class":646},[640,1986,683],{"class":654},[640,1988,675],{"class":650},[640,1990,647],{"class":646},[640,1992,690],{"class":654},[640,1994,1995,1997,1999,2001,2003,2005,2007,2009,2011,2013,2015,2017,2019,2021,2023,2025,2027,2029,2031],{"class":642,"line":716},[640,1996,856],{"class":646},[640,1998,651],{"class":650},[640,2000,655],{"class":654},[640,2002,860],{"class":646},[640,2004,661],{"class":650},[640,2006,664],{"class":654},[640,2008,864],{"class":646},[640,2010,661],{"class":650},[640,2012,664],{"class":654},[640,2014,667],{"class":646},[640,2016,661],{"class":650},[640,2018,672],{"class":646},[640,2020,675],{"class":650},[640,2022,574],{"class":654},[640,2024,680],{"class":646},[640,2026,683],{"class":654},[640,2028,675],{"class":650},[640,2030,856],{"class":646},[640,2032,964],{"class":654},[640,2034,2035,2037,2039,2041,2043,2046],{"class":642,"line":986},[640,2036,856],{"class":646},[640,2038,651],{"class":650},[640,2040,655],{"class":654},[640,2042,856],{"class":646},[640,2044,2045],{"class":650},"%\u002F",[640,2047,690],{"class":654},[640,2049,2050,2053,2055,2057,2059,2062,2064],{"class":642,"line":1480},[640,2051,2052],{"class":646},"saved",[640,2054,651],{"class":650},[640,2056,701],{"class":654},[640,2058,1014],{"class":646},[640,2060,2061],{"class":654},".before-restore-$(",[640,2063,710],{"class":709},[640,2065,983],{"class":654},[640,2067,2068,2070,2072,2074,2076,2078,2080,2082],{"class":642,"line":1486},[640,2069,1446],{"class":650},[640,2071,1449],{"class":646},[640,2073,1452],{"class":650},[640,2075,725],{"class":654},[640,2077,728],{"class":646},[640,2079,1459],{"class":654},[640,2081,1462],{"class":646},[640,2083,1465],{"class":650},[640,2085,2086,2088,2090,2092],{"class":642,"line":1525},[640,2087,1470],{"class":721},[640,2089,725],{"class":654},[640,2091,728],{"class":646},[640,2093,1477],{"class":654},[640,2095,2096,2098,2100,2102,2105,2107,2109,2111,2113],{"class":642,"line":1579},[640,2097,1754],{"class":650},[640,2099,1449],{"class":646},[640,2101,1821],{"class":650},[640,2103,2104],{"class":650}," -d",[640,2106,725],{"class":654},[640,2108,999],{"class":646},[640,2110,1023],{"class":654},[640,2112,1462],{"class":646},[640,2114,1465],{"class":650},[640,2116,2117,2119,2121,2123],{"class":642,"line":1596},[640,2118,1470],{"class":721},[640,2120,725],{"class":654},[640,2122,999],{"class":646},[640,2124,2125],{"class":654},"\u002Fconfig is not a folder: set files to the folder your files copy printed\"\n",[640,2127,2128,2130,2132,2134,2136,2139,2141,2143],{"class":642,"line":1852},[640,2129,1754],{"class":650},[640,2131,1449],{"class":646},[640,2133,1452],{"class":650},[640,2135,725],{"class":654},[640,2137,2138],{"class":646},"$saved",[640,2140,701],{"class":654},[640,2142,1462],{"class":646},[640,2144,1465],{"class":650},[640,2146,2147,2149,2151,2153],{"class":642,"line":1896},[640,2148,1470],{"class":721},[640,2150,725],{"class":654},[640,2152,2138],{"class":646},[640,2154,2155],{"class":654}," is already there: run this again\"\n",[640,2157,2159,2161,2163,2166,2168,2170,2172,2175,2177,2180,2182,2184,2186,2188,2190,2192,2194,2196],{"class":642,"line":2158},12,[640,2160,1754],{"class":650},[640,2162,1449],{"class":646},[640,2164,2165],{"class":650},"-d",[640,2167,725],{"class":654},[640,2169,1014],{"class":646},[640,2171,701],{"class":654},[640,2173,2174],{"class":646}," ] && ",[640,2176,1821],{"class":650},[640,2178,2179],{"class":709}," cp",[640,2181,1009],{"class":721},[640,2183,725],{"class":654},[640,2185,1014],{"class":646},[640,2187,701],{"class":654},[640,2189,725],{"class":654},[640,2191,2138],{"class":646},[640,2193,701],{"class":654},[640,2195,1519],{"class":646},[640,2197,1465],{"class":650},[640,2199,2201,2203,2206,2208,2211,2213,2216,2218],{"class":642,"line":2200},13,[640,2202,1470],{"class":721},[640,2204,2205],{"class":654}," \"could not copy ",[640,2207,1014],{"class":646},[640,2209,2210],{"class":654}," to ",[640,2212,2138],{"class":646},[640,2214,2215],{"class":654},": nothing was restored. Delete ",[640,2217,2138],{"class":646},[640,2219,2220],{"class":654}," if it is there, fix the cause, and run this again\"\n",[640,2222,2224],{"class":642,"line":2223},14,[640,2225,1483],{"class":650},[640,2227,2229,2232,2234,2236,2238,2240,2242,2244,2246,2249,2252,2254,2256,2258,2261],{"class":642,"line":2228},15,[640,2230,2231],{"class":650},"  if",[640,2233,1449],{"class":646},[640,2235,2165],{"class":650},[640,2237,725],{"class":654},[640,2239,2138],{"class":646},[640,2241,701],{"class":654},[640,2243,1462],{"class":646},[640,2245,1548],{"class":650},[640,2247,2248],{"class":721}," echo",[640,2250,2251],{"class":654}," \"the config you had is kept at ",[640,2253,2138],{"class":646},[640,2255,701],{"class":654},[640,2257,1519],{"class":646},[640,2259,2260],{"class":650},"fi",[640,2262,2263],{"class":646}," &&\n",[640,2265,2267,2270,2273,2275,2277,2279,2281,2283,2285],{"class":642,"line":2266},16,[640,2268,2269],{"class":709},"    mkdir",[640,2271,2272],{"class":721}," -p",[640,2274,725],{"class":654},[640,2276,1014],{"class":646},[640,2278,701],{"class":654},[640,2280,725],{"class":654},[640,2282,728],{"class":646},[640,2284,1036],{"class":654},[640,2286,2263],{"class":646},[640,2288,2290,2293,2296,2298,2300,2303,2305,2307,2310],{"class":642,"line":2289},17,[640,2291,2292],{"class":709},"    cp",[640,2294,2295],{"class":721}," -R",[640,2297,725],{"class":654},[640,2299,999],{"class":646},[640,2301,2302],{"class":654},"\u002Fconfig\u002F.\"",[640,2304,725],{"class":654},[640,2306,1014],{"class":646},[640,2308,2309],{"class":654},"\u002F\"",[640,2311,2263],{"class":646},[640,2313,2315,2317,2319,2321,2323,2325,2327,2329,2331,2333,2335,2337,2339,2342,2344,2346,2349,2351,2353],{"class":642,"line":2314},18,[640,2316,1528],{"class":650},[640,2318,1449],{"class":646},[640,2320,2165],{"class":650},[640,2322,725],{"class":654},[640,2324,999],{"class":646},[640,2326,1036],{"class":654},[640,2328,1462],{"class":646},[640,2330,1548],{"class":650},[640,2332,2179],{"class":709},[640,2334,2295],{"class":721},[640,2336,725],{"class":654},[640,2338,999],{"class":646},[640,2340,2341],{"class":654},"\u002Fattachments\u002F.\"",[640,2343,725],{"class":654},[640,2345,728],{"class":646},[640,2347,2348],{"class":654},"\u002Fattachments\u002F\"",[640,2350,1519],{"class":646},[640,2352,2260],{"class":650},[640,2354,2263],{"class":646},[640,2356,2358,2361,2363,2365],{"class":642,"line":2357},19,[640,2359,2360],{"class":709},"    ls",[640,2362,725],{"class":654},[640,2364,1014],{"class":646},[640,2366,767],{"class":654},[640,2368,2370],{"class":642,"line":2369},20,[640,2371,1576],{"class":650},[624,2373],{},"It names the folder that keeps the config you had, then lists the files that are\nback. If ",[541,2376,1006],{}," prints an error after that name, the restore stopped partway: the\nnamed folder still holds everything you had. Any other message means nothing was\nrestored: act on it and run the block again.",[624,2379],{},"Each run makes a new dated folder, so the oldest one holds what you had before\nthe first run. Delete it once Kraft runs on the restored config and you no\nlonger need what the old files held. Until then it is the only copy of them.",[624,2382],{},[541,2384,2385],{},"attachments\u002F"," is only added to: ",[541,2388,2389],{},"cp -R"," replaces a file of the same name and\nremoves none, so an attachment you added since the backup stays.",[538,2392,2393,2394,2397,2398,2401,2402,574],{},"Start the Kraft release that wrote the backup, with ",[541,2395,2396],{},"kraft admin start --detach","\n(or ",[541,2399,2400],{},"kraft admin install-service"," if you removed the service in step 1). To\ngo back a release first, see\n",[550,2403,2405],{"href":2404},"\u002Fguides\u002Frun\u002Fupgrade-kraft#pin-or-roll-back-a-version","Pin or roll back a version",[526,2407,2408,2410],{},[541,2409,2396],{}," prints the address and the server's process id:",[631,2412,2415],{"className":2413,"code":2414,"language":773,"meta":636},[771],"kraft: http:\u002F\u002F127.0.0.1:8765 (pid 48213, detached - kraft admin stop)\n",[541,2416,2417],{"__ignoreMap":636},[640,2418,2414],{"className":2419},[642],[526,2421,2422,2423,2426,2427,2429,2430,2432],{},"You know it worked when ",[541,2424,2425],{},"kraft view list --all"," shows the items the backup held.\n",[541,2428,1084],{}," needs no restore: the server rescans repo documents when it\nstarts, and ",[541,2431,1088],{}," rescans them on demand.",[526,2434,2435,2437,2438,2440,2441,2443,2444,2446,2447,2450,2451,2454,2455,574],{},[541,2436,843],{}," needs none either. When the restored ",[541,2439,566],{}," holds\n",[541,2442,834],{},", the server fetches each installed add-on again at its locked\ncommit after it starts, in the background, and loads it once its files match\nthe locked digest. The same happens when you copy ",[541,2445,566],{}," to a new machine.\nThe machine needs git access to each collection's URL. ",[541,2448,2449],{},"kraft admin doctor","\nnames an add-on that is not back on its ",[541,2452,2453],{},"add-ons"," row. See\n",[550,2456,2458],{"href":2457},"\u002Freference\u002Fconfiguration\u002Faddons#restoring-a-store","Restoring a store",[1091,2460,2462],{"id":2461},"if-the-restore-went-wrong","If the restore went wrong",[526,2464,2465,2466,2468],{},"If the board is empty or shows the wrong items, put the old database back. The\ncopy in the ",[541,2467,1626],{}," folder is untouched.",[618,2470,2471,2474,2659,2965],{},[538,2472,2473],{},"Stop the server, as in step 1.",[538,2475,2476,2477],{},"Move the restored files into a new directory, so nothing is overwritten:",[631,2478,2480],{"className":633,"code":2479,"language":635,"meta":636,"style":636},"run=\"${KRAFT_RUN_DIR:-${KRAFT_HOME:-$HOME\u002F.kraft}\u002Frun}\"\nbad=\"$run\u002Frestored-$(date +%Y%m%d-%H%M%S)\"\nif [ -e \"$run\u002Fkraft.pid\" ]; then\n  echo \"$run\u002Fkraft.pid exists: a server may be running. If a service runs Kraft, follow Stop a service on the Run Kraft as a service page. Otherwise run kraft admin stop, which also clears a stale pid file.\"\nelse\n  mkdir \"$bad\" && for f in orchestrator.db orchestrator.db-wal orchestrator.db-shm; do\n    if [ -e \"$run\u002F$f\" ]; then mv -n \"$run\u002F$f\" \"$bad\"\u002F; fi\n  done && ls \"$bad\"\nfi\n",[541,2481,2482,2516,2534,2552,2562,2566,2595,2641,2655],{"__ignoreMap":636},[640,2483,2484,2486,2488,2490,2492,2494,2496,2498,2500,2502,2504,2506,2508,2510,2512,2514],{"class":642,"line":643},[640,2485,647],{"class":646},[640,2487,651],{"class":650},[640,2489,655],{"class":654},[640,2491,658],{"class":646},[640,2493,661],{"class":650},[640,2495,664],{"class":654},[640,2497,667],{"class":646},[640,2499,661],{"class":650},[640,2501,672],{"class":646},[640,2503,675],{"class":650},[640,2505,574],{"class":654},[640,2507,680],{"class":646},[640,2509,683],{"class":654},[640,2511,675],{"class":650},[640,2513,647],{"class":646},[640,2515,690],{"class":654},[640,2517,2518,2521,2523,2525,2527,2530,2532],{"class":642,"line":693},[640,2519,2520],{"class":646},"bad",[640,2522,651],{"class":650},[640,2524,701],{"class":654},[640,2526,728],{"class":646},[640,2528,2529],{"class":654},"\u002Frestored-$(",[640,2531,710],{"class":709},[640,2533,983],{"class":654},[640,2535,2536,2538,2540,2542,2544,2546,2548,2550],{"class":642,"line":716},[640,2537,1446],{"class":650},[640,2539,1449],{"class":646},[640,2541,1452],{"class":650},[640,2543,725],{"class":654},[640,2545,728],{"class":646},[640,2547,1459],{"class":654},[640,2549,1462],{"class":646},[640,2551,1465],{"class":650},[640,2553,2554,2556,2558,2560],{"class":642,"line":986},[640,2555,1470],{"class":721},[640,2557,725],{"class":654},[640,2559,728],{"class":646},[640,2561,1477],{"class":654},[640,2563,2564],{"class":642,"line":1480},[640,2565,1483],{"class":650},[640,2567,2568,2570,2572,2575,2577,2579,2581,2583,2585,2587,2589,2591,2593],{"class":642,"line":1486},[640,2569,1489],{"class":709},[640,2571,725],{"class":654},[640,2573,2574],{"class":646},"$bad",[640,2576,701],{"class":654},[640,2578,743],{"class":646},[640,2580,1501],{"class":650},[640,2582,1504],{"class":646},[640,2584,1507],{"class":650},[640,2586,1510],{"class":654},[640,2588,1513],{"class":654},[640,2590,1516],{"class":654},[640,2592,1519],{"class":646},[640,2594,1522],{"class":650},[640,2596,2597,2599,2601,2603,2605,2607,2609,2611,2613,2615,2617,2619,2621,2623,2625,2627,2629,2631,2633,2635,2637,2639],{"class":642,"line":1525},[640,2598,1528],{"class":650},[640,2600,1449],{"class":646},[640,2602,1452],{"class":650},[640,2604,725],{"class":654},[640,2606,728],{"class":646},[640,2608,675],{"class":654},[640,2610,1541],{"class":646},[640,2612,701],{"class":654},[640,2614,1462],{"class":646},[640,2616,1548],{"class":650},[640,2618,1551],{"class":709},[640,2620,1554],{"class":721},[640,2622,725],{"class":654},[640,2624,728],{"class":646},[640,2626,675],{"class":654},[640,2628,1541],{"class":646},[640,2630,701],{"class":654},[640,2632,725],{"class":654},[640,2634,2574],{"class":646},[640,2636,1571],{"class":654},[640,2638,1519],{"class":646},[640,2640,1576],{"class":650},[640,2642,2643,2645,2647,2649,2651,2653],{"class":642,"line":1579},[640,2644,1582],{"class":650},[640,2646,743],{"class":646},[640,2648,1587],{"class":709},[640,2650,725],{"class":654},[640,2652,2574],{"class":646},[640,2654,767],{"class":654},[640,2656,2657],{"class":642,"line":1596},[640,2658,1576],{"class":650},[538,2660,2661,2662,2664,2665,2667,2668,2671,2672,1940,2674,2953,2955,2956,2958,2959,2961,2962,2964],{},"Move the old files back. This block sets its variables itself, so it is safe in\na new terminal. The first line lists the ",[541,2663,615],{}," each\n",[541,2666,1626],{}," folder holds. Put the name of the right folder, which step 2\nof the restore made, in place of ",[541,2669,2670],{},"before-restore-20261002-093015",". The block moves nothing while a server may be\nrunning or a database file is in ",[541,2673,555],{},[631,2675,2677],{"className":633,"code":2676,"language":635,"meta":636,"style":636},"run=\"${KRAFT_RUN_DIR:-${KRAFT_HOME:-$HOME\u002F.kraft}\u002Frun}\"\nls -d \"$run\"\u002Fbefore-restore-*\u002Forchestrator.db\nsafe=\"$run\u002Fbefore-restore-20261002-093015\"\nif [ -e \"$run\u002Fkraft.pid\" ]; then\n  echo \"$run\u002Fkraft.pid exists: a server may be running. If a service runs Kraft, follow Stop a service on the Run Kraft as a service page. Otherwise run kraft admin stop, which also clears a stale pid file.\"\nelif [ -e \"$run\u002Forchestrator.db\" ] || [ -e \"$run\u002Forchestrator.db-wal\" ] || [ -e \"$run\u002Forchestrator.db-shm\" ]; then\n  echo \"a database file is still in $run: move the restored files aside first\"\nelif [ ! -d \"$safe\" ]; then\n  echo \"$safe is not a directory: check the name against the ls above\"\nelse\n  for f in orchestrator.db orchestrator.db-wal orchestrator.db-shm; do\n    if [ -e \"$safe\u002F$f\" ]; then mv -n \"$safe\u002F$f\" \"$run\"\u002F; fi\n  done && ls \"$run\"\u002Forchestrator.db*\nfi\n",[541,2678,2679,2713,2732,2745,2763,2773,2819,2831,2851,2862,2866,2885,2931,2949],{"__ignoreMap":636},[640,2680,2681,2683,2685,2687,2689,2691,2693,2695,2697,2699,2701,2703,2705,2707,2709,2711],{"class":642,"line":643},[640,2682,647],{"class":646},[640,2684,651],{"class":650},[640,2686,655],{"class":654},[640,2688,658],{"class":646},[640,2690,661],{"class":650},[640,2692,664],{"class":654},[640,2694,667],{"class":646},[640,2696,661],{"class":650},[640,2698,672],{"class":646},[640,2700,675],{"class":650},[640,2702,574],{"class":654},[640,2704,680],{"class":646},[640,2706,683],{"class":654},[640,2708,675],{"class":650},[640,2710,647],{"class":646},[640,2712,690],{"class":654},[640,2714,2715,2717,2719,2721,2723,2726,2729],{"class":642,"line":693},[640,2716,1587],{"class":709},[640,2718,2104],{"class":721},[640,2720,725],{"class":654},[640,2722,728],{"class":646},[640,2724,2725],{"class":654},"\"\u002Fbefore-restore-",[640,2727,2728],{"class":721},"*",[640,2730,2731],{"class":654},"\u002Forchestrator.db\n",[640,2733,2734,2736,2738,2740,2742],{"class":642,"line":716},[640,2735,1428],{"class":646},[640,2737,651],{"class":650},[640,2739,701],{"class":654},[640,2741,728],{"class":646},[640,2743,2744],{"class":654},"\u002Fbefore-restore-20261002-093015\"\n",[640,2746,2747,2749,2751,2753,2755,2757,2759,2761],{"class":642,"line":986},[640,2748,1446],{"class":650},[640,2750,1449],{"class":646},[640,2752,1452],{"class":650},[640,2754,725],{"class":654},[640,2756,728],{"class":646},[640,2758,1459],{"class":654},[640,2760,1462],{"class":646},[640,2762,1465],{"class":650},[640,2764,2765,2767,2769,2771],{"class":642,"line":1480},[640,2766,1470],{"class":721},[640,2768,725],{"class":654},[640,2770,728],{"class":646},[640,2772,1477],{"class":654},[640,2774,2775,2777,2779,2781,2783,2785,2787,2789,2791,2793,2795,2797,2799,2801,2803,2805,2807,2809,2811,2813,2815,2817],{"class":642,"line":1486},[640,2776,1754],{"class":650},[640,2778,1449],{"class":646},[640,2780,1452],{"class":650},[640,2782,725],{"class":654},[640,2784,728],{"class":646},[640,2786,731],{"class":654},[640,2788,1767],{"class":646},[640,2790,1770],{"class":650},[640,2792,1449],{"class":646},[640,2794,1452],{"class":650},[640,2796,725],{"class":654},[640,2798,728],{"class":646},[640,2800,1781],{"class":654},[640,2802,1767],{"class":646},[640,2804,1770],{"class":650},[640,2806,1449],{"class":646},[640,2808,1452],{"class":650},[640,2810,725],{"class":654},[640,2812,728],{"class":646},[640,2814,1796],{"class":654},[640,2816,1462],{"class":646},[640,2818,1465],{"class":650},[640,2820,2821,2823,2826,2828],{"class":642,"line":1525},[640,2822,1470],{"class":721},[640,2824,2825],{"class":654}," \"a database file is still in ",[640,2827,728],{"class":646},[640,2829,2830],{"class":654},": move the restored files aside first\"\n",[640,2832,2833,2835,2837,2839,2841,2843,2845,2847,2849],{"class":642,"line":1579},[640,2834,1754],{"class":650},[640,2836,1449],{"class":646},[640,2838,1821],{"class":650},[640,2840,2104],{"class":650},[640,2842,725],{"class":654},[640,2844,1494],{"class":646},[640,2846,701],{"class":654},[640,2848,1462],{"class":646},[640,2850,1465],{"class":650},[640,2852,2853,2855,2857,2859],{"class":642,"line":1596},[640,2854,1470],{"class":721},[640,2856,725],{"class":654},[640,2858,1494],{"class":646},[640,2860,2861],{"class":654}," is not a directory: check the name against the ls above\"\n",[640,2863,2864],{"class":642,"line":1852},[640,2865,1483],{"class":650},[640,2867,2868,2871,2873,2875,2877,2879,2881,2883],{"class":642,"line":1896},[640,2869,2870],{"class":650},"  for",[640,2872,1504],{"class":646},[640,2874,1507],{"class":650},[640,2876,1510],{"class":654},[640,2878,1513],{"class":654},[640,2880,1516],{"class":654},[640,2882,1519],{"class":646},[640,2884,1522],{"class":650},[640,2886,2887,2889,2891,2893,2895,2897,2899,2901,2903,2905,2907,2909,2911,2913,2915,2917,2919,2921,2923,2925,2927,2929],{"class":642,"line":2158},[640,2888,1528],{"class":650},[640,2890,1449],{"class":646},[640,2892,1452],{"class":650},[640,2894,725],{"class":654},[640,2896,1494],{"class":646},[640,2898,675],{"class":654},[640,2900,1541],{"class":646},[640,2902,701],{"class":654},[640,2904,1462],{"class":646},[640,2906,1548],{"class":650},[640,2908,1551],{"class":709},[640,2910,1554],{"class":721},[640,2912,725],{"class":654},[640,2914,1494],{"class":646},[640,2916,675],{"class":654},[640,2918,1541],{"class":646},[640,2920,701],{"class":654},[640,2922,725],{"class":654},[640,2924,728],{"class":646},[640,2926,1571],{"class":654},[640,2928,1519],{"class":646},[640,2930,1576],{"class":650},[640,2932,2933,2935,2937,2939,2941,2943,2946],{"class":642,"line":2200},[640,2934,1582],{"class":650},[640,2936,743],{"class":646},[640,2938,1587],{"class":709},[640,2940,725],{"class":654},[640,2942,728],{"class":646},[640,2944,2945],{"class":654},"\"\u002Forchestrator.db",[640,2947,2948],{"class":721},"*\n",[640,2950,2951],{"class":642,"line":2223},[640,2952,1576],{"class":650},[624,2954],{},"A message means nothing was moved: act on it. Otherwise the last ",[541,2957,1587],{}," lists\n",[541,2960,615],{}," back in ",[541,2963,555],{},". If it lists nothing, the folder was an empty\none: pick the one the first line listed and run the block again.",[538,2966,2967],{},"Start Kraft as in step 5 of the restore.",[530,2969,2971],{"id":2970},"the-copy-kraft-makes-before-an-upgrade","The copy Kraft makes before an upgrade",[526,2973,2974,2975,2978,2979,2982,2983,2986,2987,1662,2990,2993,2994,2997],{},"When a newer Kraft starts on an older database, it migrates the database\nforward, and the older version cannot open the result. So before it migrates,\nKraft copies the database to ",[541,2976,2977],{},"run\u002Forchestrator.db.pre-v\u003CN>-\u003Ctime>",", where ",[541,2980,2981],{},"\u003CN>","\nis the schema version it is about to migrate to and ",[541,2984,2985],{},"\u003Ctime>"," is when it made\nthe copy. Two copies in the same second get ",[541,2988,2989],{},"-2",[541,2991,2992],{},"-3"," and so on after the time. ",[541,2995,2996],{},"run\u002Flogs\u002Fserver.log"," names the file:",[631,2999,3002],{"className":3000,"code":3001,"language":773,"meta":636},[771],"database schema v44 -> v52: backed up the old database to \u002Fhome\u002Fyou\u002F.kraft\u002Frun\u002Forchestrator.db.pre-v52-20261002-093015\n",[541,3003,3004],{"__ignoreMap":636},[640,3005,3001],{"className":3006},[642],[526,3008,3009,3010,3012,3013,3016],{},"The copy is consistent even while the WAL holds recent writes, and only you\ncan read it (",[541,3011,1648],{},"). Each migration makes a new copy and never overwrites an\nolder one. If you upgrade, roll back and upgrade again, the newest\n",[541,3014,3015],{},"orchestrator.db.pre-v52-*"," is the one that holds what you did in between.",[526,3018,3019,3020,3022],{},"The copy needs about as much free space as the database, beside it in ",[541,3021,555],{},".\nIf Kraft cannot write it, it does not migrate: the server does not start, the\ndatabase is left unchanged, and the error names the copy and the space it\nneeds. Free the space and start again.",[526,3024,3025],{},"The copy loses everything done since the upgrade, and it is no substitute for\nyour own backup: make one before every upgrade. Once you are sure you will stay\non the new version, delete the copies. Kraft never deletes them itself.",[1091,3027,1656],{"id":3028},"find-the-copy-to-restore",[526,3030,1601,3031,3034],{},[541,3032,3033],{},"v\u003CN>"," in the name is the schema Kraft migrated to, not the one the copy\nholds. After more than one upgrade, the newest copy can hold a schema the\nrelease you go back to refuses. Restore the newest copy whose own schema is the\none that release runs, and 1.4's schema is 44.",[618,3036,3037,3202,3208],{},[538,3038,3039,3040,3042,3043,3127,1245,3129,3131,3132,3186,3195,3197,3198,3201],{},"Print each copy's schema, then its name, one line per copy. This only reads\nthe copies: ",[541,3041,628],{}," makes a missing file an error instead of an empty\nfile named like a copy. Names sort by schema, then by time:",[631,3044,3046],{"className":633,"code":3045,"language":635,"meta":636,"style":636},"run=\"${KRAFT_RUN_DIR:-${KRAFT_HOME:-$HOME\u002F.kraft}\u002Frun}\"\nfor f in \"$run\"\u002Forchestrator.db.pre-v*; do echo \"$(sqlite3 -readonly \"$f\" 'PRAGMA user_version') $f\"; done\n",[541,3047,3048,3082],{"__ignoreMap":636},[640,3049,3050,3052,3054,3056,3058,3060,3062,3064,3066,3068,3070,3072,3074,3076,3078,3080],{"class":642,"line":643},[640,3051,647],{"class":646},[640,3053,651],{"class":650},[640,3055,655],{"class":654},[640,3057,658],{"class":646},[640,3059,661],{"class":650},[640,3061,664],{"class":654},[640,3063,667],{"class":646},[640,3065,661],{"class":650},[640,3067,672],{"class":646},[640,3069,675],{"class":650},[640,3071,574],{"class":654},[640,3073,680],{"class":646},[640,3075,683],{"class":654},[640,3077,675],{"class":650},[640,3079,647],{"class":646},[640,3081,690],{"class":654},[640,3083,3084,3086,3088,3090,3092,3094,3097,3099,3102,3104,3107,3109,3111,3113,3115,3118,3120,3122,3124],{"class":642,"line":693},[640,3085,1501],{"class":650},[640,3087,1504],{"class":646},[640,3089,1507],{"class":650},[640,3091,725],{"class":654},[640,3093,728],{"class":646},[640,3095,3096],{"class":654},"\"\u002Forchestrator.db.pre-v*",[640,3098,1519],{"class":646},[640,3100,3101],{"class":650},"do",[640,3103,2248],{"class":721},[640,3105,3106],{"class":654}," \"$(",[640,3108,580],{"class":709},[640,3110,722],{"class":721},[640,3112,725],{"class":654},[640,3114,1541],{"class":646},[640,3116,3117],{"class":654},"\" 'PRAGMA user_version') ",[640,3119,1541],{"class":646},[640,3121,701],{"class":654},[640,3123,1519],{"class":646},[640,3125,3126],{"class":650},"done\n",[624,3128],{},[541,3130,580],{}," command, Python prints the same:",[631,3133,3135],{"className":633,"code":3134,"language":635,"meta":636,"style":636},"run=\"${KRAFT_RUN_DIR:-${KRAFT_HOME:-$HOME\u002F.kraft}\u002Frun}\"\npython3 -c 'import glob, sqlite3, sys; [print(sqlite3.connect(f\"file:{f}?mode=ro\", uri=True).execute(\"PRAGMA user_version\").fetchone()[0], f) for f in sorted(glob.glob(sys.argv[1] + \"\u002Forchestrator.db.pre-v*\"))]' \"$run\"\n",[541,3136,3137,3171],{"__ignoreMap":636},[640,3138,3139,3141,3143,3145,3147,3149,3151,3153,3155,3157,3159,3161,3163,3165,3167,3169],{"class":642,"line":643},[640,3140,647],{"class":646},[640,3142,651],{"class":650},[640,3144,655],{"class":654},[640,3146,658],{"class":646},[640,3148,661],{"class":650},[640,3150,664],{"class":654},[640,3152,667],{"class":646},[640,3154,661],{"class":650},[640,3156,672],{"class":646},[640,3158,675],{"class":650},[640,3160,574],{"class":654},[640,3162,680],{"class":646},[640,3164,683],{"class":654},[640,3166,675],{"class":650},[640,3168,647],{"class":646},[640,3170,690],{"class":654},[640,3172,3173,3175,3177,3180,3182,3184],{"class":642,"line":693},[640,3174,1156],{"class":709},[640,3176,1159],{"class":721},[640,3178,3179],{"class":654}," 'import glob, sqlite3, sys; [print(sqlite3.connect(f\"file:{f}?mode=ro\", uri=True).execute(\"PRAGMA user_version\").fetchone()[0], f) for f in sorted(glob.glob(sys.argv[1] + \"\u002Forchestrator.db.pre-v*\"))]'",[640,3181,725],{"class":654},[640,3183,728],{"class":646},[640,3185,767],{"class":654},[631,3187,3190],{"className":3188,"code":3189,"language":773,"meta":636},[771],"44 \u002Fhome\u002Fyou\u002F.kraft\u002Frun\u002Forchestrator.db.pre-v52-20261002-093015\n",[541,3191,3192],{"__ignoreMap":636},[640,3193,3189],{"className":3194},[642],[624,3196],{},"An error naming ",[541,3199,3200],{},"orchestrator.db.pre-v*",", or no lines, means Kraft made no\ncopy.",[538,3203,3204,3205,574],{},"Pick the newest line that starts with the schema you are going back to, such\nas ",[541,3206,3207],{},"44",[538,3209,3210,3211,3213,3214,3216],{},"Restore that file as in ",[550,3212,593],{"href":592},", with ",[541,3215,696],{},"\nset to its path.",[526,3218,3219,3220,574],{},"For 1.4's database, the first release you ran after 1.4 decides which copy\nholds it, and a 1.5.0 release candidate may have made none: see\n",[550,3221,3223],{"href":3222},"\u002Fguides\u002Frun\u002Fupgrade-from-0-x-or-a-release-candidate#upgrading-from-a-150-release-candidate","Upgrading from a 1.5.0 release candidate",[530,3225,3227],{"id":3226},"next-steps","Next steps",[535,3229,3230,3235,3240],{},[538,3231,3232,3234],{},[550,3233,168],{"href":169},": the upgrade steps, and how to go back to the version you had",[538,3236,3237,3239],{},[550,3238,164],{"href":165},": start Kraft at login, and stop it when a service runs it",[538,3241,3242,3245,3246,803,3248,3250],{},[550,3243,497],{"href":3244},"\u002Fproject\u002Fdata-and-privacy#secrets-and-state",": what each file in ",[541,3247,555],{},[541,3249,566],{}," holds",[3252,3253,3254],"style",{},"html pre.shiki code .s7iLA, html code.shiki .s7iLA{--shiki-light:#0E1116;--shiki-default:#0E1116;--shiki-dark:#F0F3F6}html pre.shiki code .sklAV, html code.shiki .sklAV{--shiki-light:#A0111F;--shiki-default:#A0111F;--shiki-dark:#FF9492}html pre.shiki code .semJd, html code.shiki .semJd{--shiki-light:#032563;--shiki-default:#032563;--shiki-dark:#ADDCFF}html pre.shiki code .szw1H, html code.shiki .szw1H{--shiki-light:#702C00;--shiki-default:#702C00;--shiki-dark:#FFB757}html pre.shiki code .ssYy9, html code.shiki .ssYy9{--shiki-light:#023B95;--shiki-default:#023B95;--shiki-dark:#91CBFF}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":636,"searchDepth":693,"depth":693,"links":3256},[3257,3258,3261,3262,3265,3268],{"id":532,"depth":693,"text":533},{"id":596,"depth":693,"text":597,"children":3259},[3260],{"id":1093,"depth":716,"text":585},{"id":1199,"depth":693,"text":1200},{"id":1310,"depth":693,"text":593,"children":3263},[3264],{"id":2461,"depth":716,"text":2462},{"id":2970,"depth":693,"text":2971,"children":3266},[3267],{"id":3028,"depth":716,"text":1656},{"id":3226,"depth":693,"text":3227},"Back up Kraft's database while the server runs, check the backup, restore it, and find the copy Kraft makes before an upgrade.","md",null,{},true,{"title":156,"description":3269},"PXjCBI0DR97uLn8mvTVbmScHdtkZxiPCfA0k0Gzce2Q",[3277,3279],{"title":152,"path":153,"stem":154,"description":3278,"children":-1},"Pause the items that have an agent running, restart the server, and resume them, so the restart ends no agent.",{"title":160,"path":161,"stem":162,"description":3280,"children":-1},"Where Kraft writes its logs, how to read a session's log, and how to free the disk space worktrees use.",1791801171373]