惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Martin Fowler
Martin Fowler
D
DataBreaches.Net
F
Fortinet All Blogs
阮一峰的网络日志
阮一峰的网络日志
博客园_首页
Apple Machine Learning Research
Apple Machine Learning Research
H
Help Net Security
M
MIT News - Artificial intelligence
美团技术团队
人人都是产品经理
人人都是产品经理
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
The Cloudflare Blog
有赞技术团队
有赞技术团队
L
LangChain Blog
博客园 - Franky
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 【当耐特】
S
SegmentFault 最新的问题
V
Visual Studio Blog
Blog — PlanetScale
Blog — PlanetScale
Hugging Face - Blog
Hugging Face - Blog
B
Blog
I
InfoQ

kkocdko's blog

Tasker 永久试用修改思路 - kkocdko's blog 极限压缩文档扫描件 - kkocdko's blog Bypass the Blank Chars Detection crknob - Chrome portable patch 我如何将博客首页体积降至 3 KB - kkocdko's blog 如何极限优化压缩文件体积 - kkocdko's blog EmEditor 精简版 - kkocdko's blog 优雅地游玩 Minecraft - kkocdko's blog 让程序以管理员权限运行的 PE 清单 - kkocdko's blog 注销 ZEIT 账号之后遇到的坑 - kkocdko's blog 本博客的协议已更改为 CC0 - kkocdko's blog mobp - 使 MSOffice 后台常驻 在安装 VS 生成工具时规避 .NET 安装错误 各种格式的占位空文件 - kkocdko's blog 优雅地游玩 Flash 游戏 - kkocdko's blog WPS 2016 极限精简版 - kkocdko's blog Convert Const to Let by Terser 规避 Visual Studio 许可证过期的 Bug 方便地使用 iPod - kkocdko's blog 用 UserJS 注入 UserCSS - kkocdko's blog 注册表修改文件关联(默认程序) - kkocdko's blog 周期精准的太阳系模型 - kkocdko's blog 关闭屏幕的 WinAPI - kkocdko's blog 重置 Windows 图标缓存 - kkocdko's blog AIDA64 极限精简单文件版 - kkocdko's blog 几何画板单文件精简版 - kkocdko's blog 世界之窗浏览器单文件版 - kkocdko's blog 在 MBR + Legacy 下用 Bootmgr 引导 Ubuntu 简洁的 Markdown 预览工具 - kkocdko's blog 修复 MSOffice 墨迹不可用问题 - kkocdko's blog
Backup Data from VSCode Web
2026-04-11 · via kkocdko's blog

Tested on VSCode 1.77.3. Cautions! May become invalid in a future version.

VSCode Web (like VSCode Remote, GitHub Codespaces) saves user data in IndexedDB which will be lost if you clear the browser storage.

This code snippet enables you to export and import the user data. Run on DevTools, please save your work before doing anything!

Code

(async function exportData() {
  const json = {};
  const decoder = new TextDecoder();
  for (const { name: dbName } of await indexedDB.databases()) {
    json[dbName] = {};
    const req = indexedDB.open(dbName);
    await new Promise((r) => (req.onsuccess = r));
    for (const storeName of req.result.objectStoreNames) {
      json[dbName][storeName] = {};
      const transaction = req.result.transaction(storeName);
      const store = transaction.objectStore(storeName);
      const keysReq = store.getAllKeys();
      const valuesReq = store.getAll();
      await new Promise((r) => (transaction.oncomplete = r));
      for (const k of keysReq.result) {
        const v = valuesReq.result.shift();
        const item = { type: v.constructor.name }; // String | Uint8Array
        const str = item.type === "String" ? v : decoder.decode(v);
        item.value = encodeURIComponent(str);
        json[dbName][storeName][k] = item;
      }
    }
  }
  const link = document.createElement("a");
  link.download = `vscode-web_${Date.now()}.json`;
  link.href = "data:text/json," + encodeURIComponent(JSON.stringify(json));
  link.click();
})();
(async function importData() {
  const input = document.createElement("input");
  input.type = "file";
  input.click();
  await new Promise((r) => (input.onchange = r));
  const reader = new FileReader();
  reader.readAsText(input.files[0]);
  await new Promise((r) => (reader.onload = r));
  const encoder = new TextEncoder();
  for (const [dbName, dbData] of Object.entries(JSON.parse(reader.result))) {
    const req = indexedDB.open(dbName);
    req.onupgradeneeded = ({ target: { result: db } }) =>
      Object.keys(dbData).forEach((name) => db.createObjectStore(name));
    await new Promise((r) => (req.onsuccess = r));
    for (const [storeName, storeData] of Object.entries(dbData)) {
      const transaction = req.result.transaction(storeName, "readwrite");
      const store = transaction.objectStore(storeName);
      store.clear(); // Avoid config conflict
      for (const [key, { type, value }] of Object.entries(storeData)) {
        const str = decodeURIComponent(value);
        store.put(type === "String" ? str : encoder.encode(str), key);
      }
      await new Promise((r) => (transaction.oncomplete = r));
    }
  }
  location.reload();
})();
  • To reduce backup size, try to delete log storages manually.

Change Log

20220107

  • Shorter file name.

20210729

  • Reduce code.

20210728

  • Update for VSCode 1.58.

20210405

  • First version.