> ## Documentation Index
> Fetch the complete documentation index at: https://liaobots.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Data Migration from Old Domain

> Export IndexedDB data from Android APP and restore to new site

# 📱 Data Migration from Old Domain

When a website domain becomes unavailable, you can extract locally stored IndexedDB data from the Android APP and import it to a new site.

***

## 0️⃣ Prerequisites

### Computer

| Tool         | Description                            |
| ------------ | -------------------------------------- |
| **OS**       | Windows / macOS / Linux                |
| **adb**      | Android Debug Bridge                   |
| **Terminal** | Command Prompt / PowerShell / Terminal |

#### Install adb

<Tabs>
  <Tab title="Windows">
    1. Download [SDK Platform Tools](https://developer.android.com/studio/releases/platform-tools)
    2. Extract to `C:\platform-tools`
    3. Add to system PATH (see detailed steps below)
  </Tab>

  <Tab title="macOS">
    ```bash theme={null}
    brew install android-platform-tools
    ```
  </Tab>

  <Tab title="Linux">
    ```bash theme={null}
    sudo apt install adb
    ```
  </Tab>
</Tabs>

***

### Windows: Configure Environment Variables

<Steps>
  <Step title="Open Run Dialog">
    Press `Win + R`, type `sysdm.cpl`, click OK

    <Frame>
      <img src="https://mintcdn.com/liaobots/TH469ZMeWtTsoUfC/images/export-indexeddb/run-sysdm.png?fit=max&auto=format&n=TH469ZMeWtTsoUfC&q=85&s=42a217dc48f69d3dd92c49dd713251df" alt="Run Dialog" width="728" height="382" data-path="images/export-indexeddb/run-sysdm.png" />
    </Frame>
  </Step>

  <Step title="Open System Properties">
    Select the "Advanced" tab

    <Frame>
      <img src="https://mintcdn.com/liaobots/TH469ZMeWtTsoUfC/images/export-indexeddb/system-advanced.png?fit=max&auto=format&n=TH469ZMeWtTsoUfC&q=85&s=8a8ac36968bd1c3454303a4d79caacd7" alt="System Properties" width="749" height="840" data-path="images/export-indexeddb/system-advanced.png" />
    </Frame>
  </Step>

  <Step title="Click 'Environment Variables'">
    <Frame>
      <img src="https://mintcdn.com/liaobots/TH469ZMeWtTsoUfC/images/export-indexeddb/env-button.png?fit=max&auto=format&n=TH469ZMeWtTsoUfC&q=85&s=c8322b9f2e9d56f4eb7c419d65d8861c" alt="Environment Variables Button" width="755" height="851" data-path="images/export-indexeddb/env-button.png" />
    </Frame>
  </Step>

  <Step title="Edit Path Variable">
    Find `Path` in "System variables", click "Edit"

    <Frame>
      <img src="https://mintcdn.com/liaobots/TH469ZMeWtTsoUfC/images/export-indexeddb/edit-path.png?fit=max&auto=format&n=TH469ZMeWtTsoUfC&q=85&s=375b5bc21415e0b7ffa18cd1df44b732" alt="Edit Path" width="939" height="943" data-path="images/export-indexeddb/edit-path.png" />
    </Frame>
  </Step>

  <Step title="Add adb Path">
    Click "New", enter `C:\platform-tools`, click OK

    <Frame>
      <img src="https://mintcdn.com/liaobots/TH469ZMeWtTsoUfC/images/export-indexeddb/add-path.png?fit=max&auto=format&n=TH469ZMeWtTsoUfC&q=85&s=cdf48fcfd7dd4b908c144af1a240090f" alt="Add Path" width="829" height="797" data-path="images/export-indexeddb/add-path.png" />
    </Frame>
  </Step>
</Steps>

***

### Phone

| Requirement       | Description                                          |
| ----------------- | ---------------------------------------------------- |
| **Android Phone** | With target APP installed (e.g., `com.liaobots.app`) |
| **USB Debugging** | Enabled (see steps below)                            |
| **USB Cable**     | Connect phone to computer                            |

#### Enable Developer Options and USB Debugging

1. Go to "Settings" → "About Phone"
2. Tap "Build Number" 7 times → Become a developer
3. Go back to "Settings" → "Developer Options" → Enable "USB Debugging"
4. Connect phone to computer with USB cable

***

## 1️⃣ Check adb Connection

### Verify adb Installation

```bash theme={null}
adb version
```

Shows version number if successful:

```
Android Debug Bridge version 1.0.41
```

### Connect Phone

```bash theme={null}
adb devices
```

<Warning>
  Phone will show authorization prompt → **Tap "Allow"**
</Warning>

Output example:

```
List of devices attached
ABCDEF12345    device
```

<Check>Shows `device` means connection successful</Check>

***

## 2️⃣ Find IndexedDB Data

### Enter adb shell

```bash theme={null}
adb shell
```

### Switch to App User

```bash theme={null}
run-as com.liaobots.app
```

<Warning>
  This command only works for **debug version** APK. Release APK requires root access.
</Warning>

### Navigate to IndexedDB Directory

```bash theme={null}
cd app_webview/Default/IndexedDB
ls
```

You'll see output like:

```
https_liaobots.work_0.indexeddb.leveldb
https_liaobots1.work_0.indexeddb.leveldb
https_liaobots2.work_0.indexeddb.leveldb
```

<Frame>
  <img src="https://mintcdn.com/liaobots/TH469ZMeWtTsoUfC/images/export-indexeddb/adb-shell.png?fit=max&auto=format&n=TH469ZMeWtTsoUfC&q=85&s=0bae61df76f5882e7926ca08373e1ecc" alt="adb shell operation" width="1619" height="530" data-path="images/export-indexeddb/adb-shell.png" />
</Frame>

<Check>These `.indexeddb.leveldb` folders contain your data</Check>

### Exit adb shell

```bash theme={null}
exit
exit
```

***

## 3️⃣ Export Data to Computer

Run in computer terminal (not adb shell):

```bash theme={null}
adb exec-out run-as com.liaobots.app tar cf - app_webview/Default/IndexedDB > IndexedDB_backup.tar
```

<Frame>
  <img src="https://mintcdn.com/liaobots/TH469ZMeWtTsoUfC/images/export-indexeddb/export-cmd.png?fit=max&auto=format&n=TH469ZMeWtTsoUfC&q=85&s=6cc3f2af9b86fe80f4890ab98ee1d1f3" alt="Export Command" width="1650" height="219" data-path="images/export-indexeddb/export-cmd.png" />
</Frame>

This creates `IndexedDB_backup.tar` in current directory.

### Extract File

<Tabs>
  <Tab title="Windows">
    ```bash theme={null}
    tar -xf IndexedDB_backup.tar
    ```
  </Tab>

  <Tab title="macOS / Linux">
    ```bash theme={null}
    tar -xf IndexedDB_backup.tar
    ```
  </Tab>
</Tabs>

Extracted directory structure:

```
app_webview/
└── Default/
    └── IndexedDB/
        ├── https_liaobots.work_0.indexeddb.leveldb/
        ├── https_liaobots1.work_0.indexeddb.leveldb/
        └── ...
```

***

## 4️⃣ Restore Data to New Site

1. Visit the data recovery page on new site (e.g., `/downloadjson`)
2. Click "Select IndexedDB Folder"
3. Select the extracted `.indexeddb.leveldb` folder

<Frame caption="Select the https_xxx.indexeddb.leveldb folder">
  <img src="https://mintcdn.com/liaobots/TH469ZMeWtTsoUfC/images/export-indexeddb/select-folder.jpg?fit=max&auto=format&n=TH469ZMeWtTsoUfC&q=85&s=4a7fbd158889109de5d305312967b540" alt="Select Folder" width="2266" height="554" data-path="images/export-indexeddb/select-folder.jpg" />
</Frame>

<Warning>
  Make sure to select the `.indexeddb.leveldb` folder, NOT the `.indexeddb.blob` folder
</Warning>

4. Wait for parsing to complete, download JSON file
5. Import JSON file to new site to restore data

***

## ❓ FAQ

<AccordionGroup>
  <Accordion title="run-as command shows 'Package not debuggable'">
    The APK is a release version, not debug. You need a debug APK or root access.
  </Accordion>

  <Accordion title="adb devices shows unauthorized">
    You didn't tap "Allow" on phone. Check for authorization popup on phone screen.
  </Accordion>

  <Accordion title="Exported tar file is empty">
    Check if path is correct. Use `adb shell` to verify files exist on phone first.
  </Accordion>

  <Accordion title="tar command not found on Windows">
    Windows 10+ includes tar. If not available, use 7-Zip to extract.
  </Accordion>
</AccordionGroup>

***

## 📝 Command Cheatsheet

| Step               | Command                                                                                              |
| ------------------ | ---------------------------------------------------------------------------------------------------- |
| Check adb version  | `adb version`                                                                                        |
| List devices       | `adb devices`                                                                                        |
| Enter shell        | `adb shell`                                                                                          |
| Switch to app user | `run-as com.liaobots.app`                                                                            |
| View IndexedDB     | `ls app_webview/Default/IndexedDB`                                                                   |
| Export data        | `adb exec-out run-as com.liaobots.app tar cf - app_webview/Default/IndexedDB > IndexedDB_backup.tar` |
| Extract            | `tar -xf IndexedDB_backup.tar`                                                                       |
