diff --git a/.gitattributes b/.gitattributes
index 806f91b..33aca80 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -6,5 +6,8 @@
.gitignore text eol=lf
LICENSE text eol=lf
Makefile text eol=lf
-package/openwrt-full-backup/files/usr/sbin/owrt-full-backup text eol=lf
-package/openwrt-full-backup/files/etc/config/fullbackup text eol=lf
+install.sh text eol=lf
+uninstall.sh text eol=lf
+files/usr/sbin/owrt-full-backup text eol=lf
+files/etc/config/fullbackup text eol=lf
+files/www/cgi-bin/owrt-full-backup text eol=lf
diff --git a/.gitignore b/.gitignore
index b3eddd0..772c9e5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
*.ipk
*.tar.gz
*.tar.gz.sha256
+.test-output/
build_dir/
bin/
dl/
diff --git a/README.md b/README.md
index b765696..9b94ff2 100644
--- a/README.md
+++ b/README.md
@@ -1,101 +1,97 @@
-# openwrt-full-backup
+# OpenWrt Full Backup Web
-OpenWrt package overlay for creating and restoring a single backup archive with:
+Direct web panel for OpenWrt backup and restore. No OpenWrt buildroot package or `.ipk` build is required.
-- sysupgrade configuration backup;
-- installed package list and opkg metadata;
-- OpenWrt release, board, mount, partition and UCI metadata;
-- optional `/overlay/upper` snapshot;
-- optional `/rom` read-only rootfs snapshot;
-- optional copy of a sysupgrade firmware image;
-- optional raw MTD dumps for same-device disaster recovery.
+It installs:
-The scripts target OpenWrt `/bin/sh` (BusyBox ash) and are intended for OpenWrt 22.x, 23.x, 24.x and 25.x.
+- `/usr/sbin/owrt-full-backup` command line helper;
+- `/www/cgi-bin/owrt-full-backup` web panel;
+- `/etc/config/fullbackup` defaults;
+- `/etc/owrt-full-backup/web.key` secret web key.
-## Build
+Target: OpenWrt 22.x, 23.x, 24.x and 25.x.
-Copy this repository into an OpenWrt build tree, or copy `package/openwrt-full-backup` into the build tree `package/` directory.
+## Install From Git
```sh
-make menuconfig
-# Utilities -> openwrt-full-backup
-make package/openwrt-full-backup/compile V=s
+git clone https://github.com/kzolotarev95/openwrt-full-backup.git
+cd openwrt-full-backup
+sh install.sh
```
-The package installs two commands:
+One-line install:
```sh
-owrt-full-backup
-owrt-backup
+wget -O - https://raw.githubusercontent.com/kzolotarev95/openwrt-full-backup/main/install.sh | sh
```
-## Create Backup
+The installer prints a private panel link:
-Recommended backup to USB or another persistent mount:
+```text
+http://192.168.1.1/cgi-bin/owrt-full-backup?key=SECRET
+```
+
+Keep this link private.
+
+## Web Panel
+
+The panel can:
+
+- create a full backup archive;
+- download created archives;
+- inspect an existing archive;
+- restore configs;
+- optionally reinstall saved package list;
+- optionally restore overlay;
+- optionally flash firmware image from the archive;
+- save default backup settings.
+
+Restore from the web panel does not reinstall packages unless you tick that checkbox.
+
+## Remove
+
+From a cloned repo:
+
+```sh
+sh uninstall.sh
+```
+
+One-line remove:
+
+```sh
+wget -O - https://raw.githubusercontent.com/kzolotarev95/openwrt-full-backup/main/uninstall.sh | sh
+```
+
+Remove config and web key too:
+
+```sh
+wget -O - https://raw.githubusercontent.com/kzolotarev95/openwrt-full-backup/main/uninstall.sh | PURGE=1 sh
+```
+
+Backup archives are not deleted by uninstall.
+
+## CLI Examples
+
+Create backup to USB:
```sh
owrt-full-backup create -o /mnt/usb
```
-Include the exact sysupgrade image if you have it on the router:
+Include firmware image if it is already on the router:
```sh
owrt-full-backup create -o /mnt/usb --firmware-image /tmp/openwrt-sysupgrade.bin
```
-Include the read-only firmware root filesystem snapshot:
+Inspect backup:
```sh
-owrt-full-backup create -o /mnt/usb --include-rom
+owrt-full-backup inspect /mnt/usb/router-owrt-full-backup.tar.gz
```
-Create a same-device raw flash dump too:
+Restore configs only:
```sh
-owrt-full-backup create -o /mnt/usb --include-raw-mtd
+owrt-full-backup restore /mnt/usb/router-owrt-full-backup.tar.gz --yes --no-packages
```
-
-Raw MTD dumps are not portable between different models or partition layouts.
-
-## Restore
-
-Safe restore mode restores configs and reinstalls packages from feeds:
-
-```sh
-owrt-full-backup restore /mnt/usb/router-backup.tar.gz --yes
-```
-
-Restore only configs:
-
-```sh
-owrt-full-backup restore /mnt/usb/router-backup.tar.gz --yes --no-packages
-```
-
-Restore the overlay snapshot too, only on the same device and preferably the same OpenWrt release:
-
-```sh
-owrt-full-backup restore /mnt/usb/router-backup.tar.gz --yes --overlay
-```
-
-Flash firmware from the archive:
-
-```sh
-owrt-full-backup restore /mnt/usb/router-backup.tar.gz --yes --flash-firmware
-```
-
-Firmware flashing uses `sysupgrade` and reboots the device. The original OpenWrt sysupgrade image is usually not stored on the router, so include it at backup time with `--firmware-image` if you need this.
-
-## Default Config
-
-The package installs `/etc/config/fullbackup`:
-
-```uci
-config backup 'main'
- option output_dir '/tmp'
- option include_overlay '1'
- option include_rom '0'
- option include_raw_mtd '0'
- option keep_days '0'
-```
-
-Use `/tmp` only for quick tests. Real backups should go to USB, network storage, or a mounted persistent disk.
diff --git a/package/openwrt-full-backup/files/etc/config/fullbackup b/files/etc/config/fullbackup
similarity index 100%
rename from package/openwrt-full-backup/files/etc/config/fullbackup
rename to files/etc/config/fullbackup
diff --git a/package/openwrt-full-backup/files/usr/sbin/owrt-full-backup b/files/usr/sbin/owrt-full-backup
similarity index 100%
rename from package/openwrt-full-backup/files/usr/sbin/owrt-full-backup
rename to files/usr/sbin/owrt-full-backup
diff --git a/files/www/cgi-bin/owrt-full-backup b/files/www/cgi-bin/owrt-full-backup
new file mode 100644
index 0000000..61e56c0
--- /dev/null
+++ b/files/www/cgi-bin/owrt-full-backup
@@ -0,0 +1,483 @@
+#!/bin/sh
+
+BACKEND="${BACKEND:-/usr/sbin/owrt-full-backup}"
+KEY_FILE="${KEY_FILE:-/etc/owrt-full-backup/web.key}"
+PARAMS_FILE="${TMPDIR:-/tmp}/owrt-full-backup-cgi.$$"
+RESULT_FILE=""
+RESULT_TITLE=""
+RESULT_CODE=""
+PROJECT_URL="${PROJECT_URL:-https://github.com/kzolotarev95/openwrt-full-backup}"
+RAW_URL="${RAW_URL:-https://raw.githubusercontent.com/kzolotarev95/openwrt-full-backup/main}"
+
+cleanup() {
+ rm -f "$PARAMS_FILE"
+ if [ -n "$RESULT_FILE" ]; then
+ rm -f "$RESULT_FILE"
+ fi
+}
+
+trap cleanup EXIT INT TERM
+
+html_escape() {
+ sed 's/&/\&/g; s/\</g; s/>/\>/g; s/"/\"/g'
+}
+
+h() {
+ printf '%s' "$1" | html_escape
+}
+
+url_decode() {
+ local data
+ data="$(printf '%s' "$1" | sed 's/+/ /g; s/%/\\x/g')"
+ printf '%b' "$data"
+}
+
+parse_params() {
+ local data old_ifs pair key value
+ data="$1"
+ old_ifs="$IFS"
+ IFS='&'
+ for pair in $data; do
+ key="${pair%%=*}"
+ value="${pair#*=}"
+ [ "$pair" = "$key" ] && value=""
+ key="$(url_decode "$key" | tr -d '\r\n\t')"
+ value="$(url_decode "$value" | tr '\r\n\t' ' ')"
+ [ -n "$key" ] && printf '%s\t%s\n' "$key" "$value" >>"$PARAMS_FILE"
+ done
+ IFS="$old_ifs"
+}
+
+param() {
+ awk -F ' ' -v k="$1" '$1 == k { print $2; exit }' "$PARAMS_FILE"
+}
+
+has_param() {
+ awk -F ' ' -v k="$1" '$1 == k { found = 1 } END { exit(found ? 0 : 1) }' "$PARAMS_FILE"
+}
+
+read_request() {
+ local post_data
+ : >"$PARAMS_FILE"
+ parse_params "${QUERY_STRING:-}"
+ if [ "${REQUEST_METHOD:-GET}" = "POST" ] && [ -n "${CONTENT_LENGTH:-}" ]; then
+ post_data="$(dd bs=1 count="$CONTENT_LENGTH" 2>/dev/null)"
+ parse_params "$post_data"
+ fi
+}
+
+config_get() {
+ local key default value
+ key="$1"
+ default="$2"
+ if command -v uci >/dev/null 2>&1; then
+ value="$(uci -q get "fullbackup.main.$key" 2>/dev/null || true)"
+ [ -n "$value" ] && {
+ printf '%s' "$value"
+ return
+ }
+ fi
+ printf '%s' "$default"
+}
+
+web_key() {
+ cat "$KEY_FILE" 2>/dev/null
+}
+
+self_url() {
+ printf '%s' "${SCRIPT_NAME:-/cgi-bin/owrt-full-backup}"
+}
+
+authorized() {
+ local expected supplied
+ expected="$(web_key)"
+ supplied="$(param key)"
+ [ -n "$expected" ] && [ "$supplied" = "$expected" ]
+}
+
+http_html() {
+ printf 'Content-Type: text/html; charset=utf-8\r\n\r\n'
+}
+
+http_unauthorized() {
+ http_html
+ cat <<'EOF'
+
OpenWrt Full Backup
+Access denied
Open the panel with the secret key printed by install.sh.
+EOF
+}
+
+valid_abs_path() {
+ case "$1" in
+ /*) ;;
+ *) return 1 ;;
+ esac
+ printf '%s' "$1" | grep -Eq '^/[A-Za-z0-9._/-]+$'
+}
+
+download_file() {
+ local file base
+ file="$(param file)"
+ valid_abs_path "$file" || {
+ http_html
+ printf 'Bad file path.
'
+ exit 0
+ }
+ case "$file" in
+ *.tar.gz|*.tar.gz.sha256) ;;
+ *) http_html; printf 'Only backup archives and checksums can be downloaded.
'; exit 0 ;;
+ esac
+ [ -f "$file" ] || {
+ http_html
+ printf 'File not found.
'
+ exit 0
+ }
+ base="$(basename "$file")"
+ case "$file" in
+ *.sha256) printf 'Content-Type: text/plain\r\n' ;;
+ *) printf 'Content-Type: application/gzip\r\n' ;;
+ esac
+ printf 'Content-Disposition: attachment; filename="%s"\r\n\r\n' "$base"
+ cat "$file"
+ exit 0
+}
+
+run_backend() {
+ RESULT_TITLE="$1"
+ shift
+ RESULT_FILE="${TMPDIR:-/tmp}/owrt-full-backup-result.$$"
+ if [ ! -x "$BACKEND" ]; then
+ RESULT_CODE=127
+ printf 'Backend is not installed: %s\n' "$BACKEND" >"$RESULT_FILE"
+ return
+ fi
+ "$BACKEND" "$@" >"$RESULT_FILE" 2>&1
+ RESULT_CODE="$?"
+}
+
+handle_create() {
+ local output_dir name firmware
+ output_dir="$(param output_dir)"
+ name="$(param name)"
+ firmware="$(param firmware_image)"
+ [ -n "$output_dir" ] || output_dir="$(config_get output_dir /tmp)"
+ valid_abs_path "$output_dir" || {
+ RESULT_TITLE="Create backup"
+ RESULT_CODE=2
+ RESULT_FILE="${TMPDIR:-/tmp}/owrt-full-backup-result.$$"
+ printf 'Bad output directory. Use an absolute path, for example /mnt/usb.\n' >"$RESULT_FILE"
+ return
+ }
+
+ set -- create -o "$output_dir"
+ [ -n "$name" ] && set -- "$@" -n "$name"
+ has_param include_overlay || set -- "$@" --no-overlay
+ has_param include_rom && set -- "$@" --include-rom
+ has_param include_raw_mtd && set -- "$@" --include-raw-mtd
+ [ -n "$firmware" ] && set -- "$@" --firmware-image "$firmware"
+ run_backend "Create backup" "$@"
+}
+
+handle_inspect() {
+ local archive
+ archive="$(param archive)"
+ valid_abs_path "$archive" || {
+ RESULT_TITLE="Inspect backup"
+ RESULT_CODE=2
+ RESULT_FILE="${TMPDIR:-/tmp}/owrt-full-backup-result.$$"
+ printf 'Bad archive path.\n' >"$RESULT_FILE"
+ return
+ }
+ run_backend "Inspect backup" inspect "$archive"
+}
+
+handle_restore() {
+ local archive confirm
+ archive="$(param archive)"
+ confirm="$(param confirm)"
+ if [ "$confirm" != "RESTORE" ]; then
+ RESULT_TITLE="Restore backup"
+ RESULT_CODE=2
+ RESULT_FILE="${TMPDIR:-/tmp}/owrt-full-backup-result.$$"
+ printf 'Type RESTORE to confirm restore.\n' >"$RESULT_FILE"
+ return
+ fi
+ valid_abs_path "$archive" || {
+ RESULT_TITLE="Restore backup"
+ RESULT_CODE=2
+ RESULT_FILE="${TMPDIR:-/tmp}/owrt-full-backup-result.$$"
+ printf 'Bad archive path.\n' >"$RESULT_FILE"
+ return
+ }
+
+ set -- restore "$archive" --yes
+ has_param restore_configs || set -- "$@" --no-configs
+ has_param restore_packages || set -- "$@" --no-packages
+ has_param restore_overlay && set -- "$@" --overlay
+ has_param flash_firmware && set -- "$@" --flash-firmware
+ run_backend "Restore backup" "$@"
+}
+
+handle_save_defaults() {
+ local output_dir include_overlay include_rom include_raw_mtd keep_days
+ RESULT_TITLE="Save defaults"
+ RESULT_CODE=0
+ RESULT_FILE="${TMPDIR:-/tmp}/owrt-full-backup-result.$$"
+ output_dir="$(param default_output_dir)"
+ keep_days="$(param keep_days)"
+ valid_abs_path "$output_dir" || {
+ RESULT_CODE=2
+ printf 'Bad output directory.\n' >"$RESULT_FILE"
+ return
+ }
+ case "$keep_days" in ''|*[!0-9]*) keep_days=0 ;; esac
+ has_param default_include_overlay && include_overlay=1 || include_overlay=0
+ has_param default_include_rom && include_rom=1 || include_rom=0
+ has_param default_include_raw_mtd && include_raw_mtd=1 || include_raw_mtd=0
+
+ if command -v uci >/dev/null 2>&1; then
+ uci -q batch <"$RESULT_FILE" 2>&1
+set fullbackup.main=backup
+set fullbackup.main.output_dir='$output_dir'
+set fullbackup.main.include_overlay='$include_overlay'
+set fullbackup.main.include_rom='$include_rom'
+set fullbackup.main.include_raw_mtd='$include_raw_mtd'
+set fullbackup.main.keep_days='$keep_days'
+commit fullbackup
+EOF
+ RESULT_CODE="$?"
+ [ "$RESULT_CODE" = "0" ] && printf 'Defaults saved.\n' >>"$RESULT_FILE"
+ else
+ RESULT_CODE=127
+ printf 'uci command not found.\n' >"$RESULT_FILE"
+ fi
+}
+
+handle_action() {
+ local action
+ action="$(param action)"
+ case "$action" in
+ create) handle_create ;;
+ inspect) handle_inspect ;;
+ restore) handle_restore ;;
+ save_defaults) handle_save_defaults ;;
+ esac
+}
+
+system_value() {
+ case "$1" in
+ host) hostname 2>/dev/null || printf 'openwrt' ;;
+ release)
+ if [ -r /etc/openwrt_release ]; then
+ . /etc/openwrt_release 2>/dev/null
+ printf '%s %s' "${DISTRIB_ID:-OpenWrt}" "${DISTRIB_RELEASE:-unknown}"
+ else
+ printf 'OpenWrt unknown'
+ fi
+ ;;
+ board)
+ if [ -r /tmp/sysinfo/board_name ]; then
+ cat /tmp/sysinfo/board_name
+ else
+ printf 'unknown'
+ fi
+ ;;
+ esac
+}
+
+checkbox_attr() {
+ [ "$1" = "1" ] && printf ' checked'
+}
+
+backup_rows() {
+ local dir key file base size mtime
+ dir="$(config_get output_dir /tmp)"
+ key="$(h "$(param key)")"
+ [ -d "$dir" ] || {
+ printf '| Output directory does not exist. |
'
+ return
+ }
+ for file in "$dir"/*-owrt-full-backup.tar.gz; do
+ [ -f "$file" ] || continue
+ base="$(basename "$file")"
+ size="$(ls -lh "$file" 2>/dev/null | awk '{print $5}')"
+ mtime="$(ls -l "$file" 2>/dev/null | awk '{print $6" "$7" "$8}')"
+ printf '%s | %s | %s | download |
' \
+ "$(h "$base")" "$(h "$size")" "$(h "$mtime")" "$(self_url)" "$key" "$(h "$file")"
+ done
+}
+
+page() {
+ local key output_dir include_overlay include_rom include_raw_mtd keep_days
+ key="$(h "$(param key)")"
+ output_dir="$(config_get output_dir /tmp)"
+ include_overlay="$(config_get include_overlay 1)"
+ include_rom="$(config_get include_rom 0)"
+ include_raw_mtd="$(config_get include_raw_mtd 0)"
+ keep_days="$(config_get keep_days 0)"
+
+ http_html
+ cat <
+
+
+
+
+OpenWrt Full Backup
+
+
+
+
+
+EOF
+
+ if [ -n "$RESULT_FILE" ]; then
+ printf '%s
Exit code: %s
' "$(h "$RESULT_TITLE")" "$(h "$RESULT_CODE")"
+ html_escape <"$RESULT_FILE"
+ printf '
'
+ fi
+
+ cat <
+
+
Device
+
+Host: $(h "$(system_value host)")
+Release: $(h "$(system_value release)")
+Board: $(h "$(system_value board)")
+
+
$(df -h 2>/dev/null | html_escape)
+
+
+
+
+
+
Backups in $(h "$output_dir")
+
| File | Size | Date | Action |
+$(backup_rows)
+
+
+
+
+
+
+
+
+
+
+
Git install / remove
+
Clone install:
+
git clone $(h "$PROJECT_URL").git
+cd openwrt-full-backup
+sh install.sh
+
One-line install:
+
wget -O - $(h "$RAW_URL")/install.sh | sh
+
Remove:
+
wget -O - $(h "$RAW_URL")/uninstall.sh | sh
+
+
+
+
+
+EOF
+}
+
+read_request
+if ! authorized; then
+ http_unauthorized
+ exit 0
+fi
+
+if [ "$(param action)" = "download" ]; then
+ download_file
+fi
+
+if [ "${REQUEST_METHOD:-GET}" = "POST" ]; then
+ handle_action
+fi
+
+page
diff --git a/install.sh b/install.sh
new file mode 100644
index 0000000..0ba03ca
--- /dev/null
+++ b/install.sh
@@ -0,0 +1,116 @@
+#!/bin/sh
+
+set -eu
+
+RAW_URL="${RAW_URL:-https://raw.githubusercontent.com/kzolotarev95/openwrt-full-backup/main}"
+ROOT="${ROOT:-/}"
+SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" 2>/dev/null && pwd)"
+
+info() {
+ printf '%s\n' "$*"
+}
+
+die() {
+ printf 'ERROR: %s\n' "$*" >&2
+ exit 1
+}
+
+target_path() {
+ printf '%s/%s' "${ROOT%/}" "$1"
+}
+
+fetch() {
+ local src dst
+ src="$1"
+ dst="$2"
+ if command -v wget >/dev/null 2>&1; then
+ wget -O "$dst" "$src"
+ elif command -v curl >/dev/null 2>&1; then
+ curl -fsSL "$src" -o "$dst"
+ else
+ die "wget or curl is required for remote install"
+ fi
+}
+
+install_file() {
+ local rel mode src dst
+ rel="$1"
+ mode="$2"
+ src="$SCRIPT_DIR/files/$rel"
+ dst="$(target_path "$rel")"
+ mkdir -p "$(dirname "$dst")"
+ if [ -f "$src" ]; then
+ cp "$src" "$dst"
+ else
+ fetch "$RAW_URL/files/$rel" "$dst"
+ fi
+ chmod "$mode" "$dst"
+}
+
+install_config() {
+ local rel src dst
+ rel="etc/config/fullbackup"
+ src="$SCRIPT_DIR/files/$rel"
+ dst="$(target_path "$rel")"
+ mkdir -p "$(dirname "$dst")"
+ if [ -f "$dst" ]; then
+ info "Keeping existing $dst"
+ return
+ fi
+ if [ -f "$src" ]; then
+ cp "$src" "$dst"
+ else
+ fetch "$RAW_URL/files/$rel" "$dst"
+ fi
+ chmod 0644 "$dst"
+}
+
+make_key() {
+ local key_dir key_file key
+ key_dir="$(target_path etc/owrt-full-backup)"
+ key_file="$key_dir/web.key"
+ mkdir -p "$key_dir"
+ if [ ! -s "$key_file" ]; then
+ if command -v hexdump >/dev/null 2>&1; then
+ key="$(dd if=/dev/urandom bs=16 count=1 2>/dev/null | hexdump -v -e '16/1 "%02x"')"
+ else
+ key="$(date +%s)-$$"
+ fi
+ printf '%s\n' "$key" >"$key_file"
+ fi
+ chmod 0600 "$key_file"
+ cat "$key_file"
+}
+
+router_ip() {
+ local ip
+ if command -v uci >/dev/null 2>&1; then
+ ip="$(uci -q get network.lan.ipaddr 2>/dev/null || true)"
+ if [ -n "$ip" ]; then
+ printf '%s\n' "$ip"
+ return
+ fi
+ fi
+ ip="$(hostname -I 2>/dev/null | awk '{print $1}')"
+ if [ -n "$ip" ]; then
+ printf '%s\n' "$ip"
+ return
+ fi
+ printf '192.168.1.1'
+}
+
+install_file "usr/sbin/owrt-full-backup" 0755
+ln -sf owrt-full-backup "$(target_path usr/sbin/owrt-backup)"
+install_config
+install_file "www/cgi-bin/owrt-full-backup" 0755
+
+if [ -x "$(target_path etc/init.d/uhttpd)" ]; then
+ "$(target_path etc/init.d/uhttpd)" reload >/dev/null 2>&1 || "$(target_path etc/init.d/uhttpd)" restart >/dev/null 2>&1 || true
+fi
+
+key="$(make_key)"
+ip="$(router_ip)"
+
+info "Installed OpenWrt Full Backup web panel."
+info "Open: http://$ip/cgi-bin/owrt-full-backup?key=$key"
+info "CLI: owrt-full-backup create -o /mnt/usb"
diff --git a/package/openwrt-full-backup/Makefile b/package/openwrt-full-backup/Makefile
deleted file mode 100644
index 2a47d1b..0000000
--- a/package/openwrt-full-backup/Makefile
+++ /dev/null
@@ -1,36 +0,0 @@
-include $(TOPDIR)/rules.mk
-
-PKG_NAME:=openwrt-full-backup
-PKG_VERSION:=1.0.0
-PKG_RELEASE:=1
-PKGARCH:=all
-PKG_LICENSE:=MIT
-PKG_MAINTAINER:=K. Zolotarev
-
-include $(INCLUDE_DIR)/package.mk
-
-define Package/openwrt-full-backup
- SECTION:=utils
- CATEGORY:=Utilities
- TITLE:=Full backup and restore helper for OpenWrt
-endef
-
-define Package/openwrt-full-backup/description
-Creates a portable backup archive with sysupgrade config backup, installed
-package list, OpenWrt metadata, optional overlay snapshot, optional ROM rootfs
-snapshot, optional firmware image copy, and optional raw MTD dumps. Includes
-guarded restore helpers for OpenWrt 22.x through 25.x.
-endef
-
-define Build/Compile
-endef
-
-define Package/openwrt-full-backup/install
- $(INSTALL_DIR) $(1)/usr/sbin
- $(INSTALL_BIN) ./files/usr/sbin/owrt-full-backup $(1)/usr/sbin/owrt-full-backup
- $(LN) owrt-full-backup $(1)/usr/sbin/owrt-backup
- $(INSTALL_DIR) $(1)/etc/config
- $(INSTALL_CONF) ./files/etc/config/fullbackup $(1)/etc/config/fullbackup
-endef
-
-$(eval $(call BuildPackage,openwrt-full-backup))
diff --git a/uninstall.sh b/uninstall.sh
new file mode 100644
index 0000000..c4fcc3e
--- /dev/null
+++ b/uninstall.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+set -eu
+
+ROOT="${ROOT:-/}"
+PURGE="${PURGE:-0}"
+
+target_path() {
+ printf '%s/%s' "${ROOT%/}" "$1"
+}
+
+rmf() {
+ rm -f "$(target_path "$1")"
+}
+
+rmf usr/sbin/owrt-full-backup
+rmf usr/sbin/owrt-backup
+rmf www/cgi-bin/owrt-full-backup
+
+if [ "$PURGE" = "1" ]; then
+ rmf etc/config/fullbackup
+ rmf etc/owrt-full-backup/web.key
+ rmdir "$(target_path etc/owrt-full-backup)" 2>/dev/null || true
+fi
+
+if [ -x "$(target_path etc/init.d/uhttpd)" ]; then
+ "$(target_path etc/init.d/uhttpd)" reload >/dev/null 2>&1 || "$(target_path etc/init.d/uhttpd)" restart >/dev/null 2>&1 || true
+fi
+
+printf '%s\n' "Removed OpenWrt Full Backup web panel."
+if [ "$PURGE" != "1" ]; then
+ printf '%s\n' "Config and web key were kept. Run with PURGE=1 to remove them."
+fi