File size: 2,351 Bytes
6121f2e
abdc396
 
 
 
6121f2e
abdc396
 
 
 
 
 
 
 
 
 
 
 
 
6121f2e
 
abdc396
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
---
title: OpenWebUI
emoji: πŸ€–
colorFrom: blue
colorTo: purple
sdk: docker
pinned: true
app_port: 8080
suggested_hardware: cpu-basic
suggested_storage: medium
short_description: OpenWebUI with automated GitHub data sync
tags:
  - openwebui
  - chat
  - llm
  - ai
  - docker
  - data-sync
  - backup
---

# OpenWebUI with Data Synchronization

A self-hosted OpenWebUI instance with automated data backup and synchronization to GitHub.

## Features

- πŸ€– **Full OpenWebUI**: Chat interface for AI models
- πŸ”„ **Auto Sync**: Backs up `webui.db`, `uploads/`, `vector_db/` to GitHub
- πŸ›‘οΈ **Safe Backups**: SQLite hot backups prevent corruption
- πŸ“¦ **Git LFS**: Handles large files in uploads/vector_db
- ⏰ **Configurable**: Custom sync intervals and timezone
- 🌐 **WebDAV Support**: Optional secondary backup location

## Environment Variables

Set these in your Space's **Repository Secrets**:

### Required

| Variable | Description | Example |
|----------|-------------|---------|
| `G_NAME` | GitHub repo | `username/openwebui-db` |
| `G_TOKEN` | GitHub PAT | `github_pat_xxx...` |

### Optional

| Variable | Description | Default |
|----------|-------------|---------|
| `SYNC_INTERVAL` | Sync frequency (seconds) | `3600` |
| `SYNC_TIMEZONE` | Timezone for logs | `Asia/Kolkata` |
| `GIT_USER_NAME` | Commit author | `AutoSync Bot` |
| `GIT_USER_EMAIL` | Commit email | `autosync@bot.com` |
| `WEBDAV_URL` | WebDAV server URL | - |
| `WEBDAV_USERNAME` | WebDAV user | - |
| `WEBDAV_PASSWORD` | WebDAV password | - |

## GitHub Token Setup

1. Go to [GitHub Token Settings](https://github.com/settings/tokens)
2. Create a **Fine-grained token**
3. Select your backup repository
4. Grant **Contents**: Read and Write

## Setup

1. Create a private GitHub repository for backups
2. Generate a GitHub Personal Access Token
3. Add `G_NAME` and `G_TOKEN` to Space secrets
4. Deploy and enjoy persistent storage!

## How It Works

1. **Startup**: Clones your GitHub repo and restores data
2. **Runtime**: Syncs every `SYNC_INTERVAL` seconds
3. **Backup**: Creates SQLite hot backup, syncs uploads/vector_db
4. **Push**: Commits and pushes changes to GitHub
5. **WebDAV**: Optionally uploads timestamped backup to WebDAV

Check out the [configuration reference](https://huggingface.co/docs/hub/spaces-config-reference) for more details.