#!/bin/sh red() { echo -e "\033[31m\033[01m[WARNING] $1\033[0m"; } green() { echo -e "\033[32m\033[01m[INFO] $1\033[0m"; } yellow() { echo -e "\033[33m\033[01m[NOTICE] $1\033[0m"; } blue() { echo -e "\033[34m\033[01m[MESSAGE] $1\033[0m"; } light_magenta() { echo -e "\033[95m\033[01m[NOTICE] $1\033[0m"; } light_yellow() { echo -e "\033[93m\033[01m[NOTICE] $1\033[0m"; } backup() { mkdir -p /tmp/upload cd /tmp/upload # 备份软件源配置 cp /etc/opkg/distfeeds.conf distfeeds.conf # 备份已安装软件列表 opkg list-installed > packages-list.txt # 分别备份overlay、etc目录、和usr/share目录 tar -czvf overlay_backup.tar.gz /overlay tar -czvf etc_backup.tar.gz /etc # 将所有备份打包成一个文件 tar -czvf backup.tar.gz distfeeds.conf packages-list.txt overlay_backup.tar.gz etc_backup.tar.gz # 清理临时文件 rm -rf distfeeds.conf packages-list.txt overlay_backup.tar.gz etc_backup.tar.gz green "系统备份文件已保存至 /tmp/upload/backup.tar.gz" light_magenta "请及时下载保存到电脑,恢复时使用系统——文件传输上传至/tmp/upload目录,再调用恢复脚本即可" } backup