A database/file backup tool with web interfaces

backup-x

GitHub release

带Web界面的数据库/文件备份增强工具。原理:执行自定义shell命令输出文件,增强备份功能。同时支持: 文件、mysql、postgres... English

  • 支持自定义命令
  • 支持执行shell输出的文件备份,原理上支持各种数据库/文件备份
  • 支持备份周期设置,几分钟到一年的备份周期也可以
  • 支持多个项目备份,最多16个
  • 支持备份后的文件另存到对象存储中 (在也怕删库跑路了)
  • 可设置备份文件最大保存天数
  • webhook通知

docker中使用

  • 运行docker容器(/opt/backup-x-files可替换为主机的目录)
    docker run -d --name backup-x --restart=always \
      -p 9977:9977 \
      -v /opt/backup-x-files:/app/backup-x-files \
      jeessy/backup-x
    
  • 登录 http://your_docker_ip:9977 并配置

系统中使用

  • 下载并解压https://github.com/jeessy2/backup-x/releases

  • 安装服务

    • Mac/Linux: ./backup-x -s install
    • Win(打开cmd): .\backup-x.exe -s install
    • 自定义参数 ./backup-x -s install -l 127.0.0.1:9977 -d /Users/name
      • -l 监听地址(默认监听:9977
      • -d 自定义备份目录地址(默认当前运行目录)
  • [可选] 服务卸载

    • Mac/Linux: ./backup-x -s uninstall
    • Win(打开cmd): .\backup-x.exe -s uninstall
  • 登录 http://127.0.0.1:9977 并配置

    avatar

备份脚本参考

  • postgres

    说明 备份脚本
    备份单个 PGPASSWORD="password" pg_dump --host 192.168.1.11 --port 5432 --dbname db-name --user postgres --clean --create --file #{DATE}.sql
    备份全部 PGPASSWORD="password" pg_dumpall --host 192.168.1.11 --port 5432 --user postgres --clean --file #{DATE}.sql
    还原 psql -U postgres -f 2021-11-12_10_29.sql
  • mysql/mariadb

    说明 备份脚本
    备份单个 mysqldump -h192.168.1.11 -uroot -p123456 db-name > #{DATE}.sql
    备份全部 mysqldump -h192.168.1.11 -uroot -p123456 --all-databases > #{DATE}.sql
    还原 mysql -uroot -p123456 db-name <2021-11-12_10_29.sql
  • 文件

    说明 备份脚本
    tar压缩备份 tar -zcvf #{DATE}.tar.gz /home/projects
    还原 tar -zxvf 2021-11-12_10_29.tar.gz

webhook

  • 支持webhook, 备份更新成功或不成功时, 会回调填写的URL

  • 支持的变量

    变量名 说明
    #{projectName} 项目名称
    #{fileName} 备份后的文件名称
    #{fileSize} 文件大小 (MB)
    #{result} 备份结果(成功/失败)
  • RequestBody为空GET请求,不为空POST请求

  • Server酱: https://sc.ftqq.com/[SCKEY].send?text=#{projectName}项目备份#{result},文件名:#{fileName},文件大小:#{fileSize}

  • Bark: https://api.day.app/[YOUR_KEY]/#{projectName}项目备份#{result},文件名:#{fileName},文件大小:#{fileSize}

  • 钉钉:

    • 钉钉电脑端 -> 群设置 -> 智能群助手 -> 添加机器人 -> 自定义
    • 只勾选 自定义关键词, 输入的关键字必须包含在RequestBody的content中, 如:项目备份
    • URL中输入钉钉给你的 Webhook地址
    • RequestBody中输入 {"msgtype": "text","text": {"content": "#{projectName}项目备份#{result},文件名:#{fileName},文件大小:#{fileSize}"}}

说明

  • 从backup-db发展而来,发现不仅仅支持数据库备份,所以改名backup-x,备份届的iphone-x
Comments
  • 在windows下,安装服务后。执行备份操作。提示“执行shell的输出为空”

    在windows下,安装服务后。执行备份操作。提示“执行shell的输出为空”

    2022/09/05 16:24:26 question_system项目将在0.6小时后运行 2022/09/05 16:24:26 正在备份项目: question_system ... 2022/09/05 16:24:26 执行shell的输出为空 2022/09/05 16:24:26 执行备份shell失败:

  • 日志报错。有空的话求解答一下。感谢

    日志报错。有空的话求解答一下。感谢

    2022/08/07 14:39:38 创建bucket: bitwarden 失败, ERR: AuthorizationHeaderMalformed: The authorization header is malformed; the region 'cn-north-1' is wrong; expecting 'us-west-1' status code: 400, request id: YM99XBP7RK09C90Y, host id: +h+BAP06aNfoeFZu+g8lmPLj0DjTtTaDUJw+VReegiyjUF95EyPoaXbARFqBAVm99+kmlhJk+Mc= 2022/08/07 14:39:38 正在备份项目: bitwarden_backup ... 2022/08/07 14:39:38 bitwarden_backup项目将在10.3小时后运行 2022/08/07 14:39:38 bitwarden_backup 执行shell的输出: 鼠标移动此处查看 2022/08/07 14:39:38 执行备份shell失败: time='2022-08-07T14:39:38+08:00' level=info msg='Starting sync' time='2022-08-07T14:39:38+08:00' level=error msg='Sync error: pipeline step: 0 (ListSource) failed with error: stat /root/bitwarden/data/db.sqlite3: no such file or directory, terminating' time='2022-08-07T14:39:38+08:00' level=info msg='Pipeline step finished' ErrorObj=1 InputObj=0 InputObjSpeed=0 OutputObj=0 OutputObjSpeed=0 stepName=ListSource stepNum=0 time='2022-08-07T14:39:38+08:00' level=info msg='Pipeline step finished' ErrorObj=0 InputObj=0 InputObjSpeed=0 OutputObj=0 OutputObjSpeed=0 stepName=FilterObjectsExistNot stepNum=1 time='2022-08-07T14:39:38+08:00' level=info msg='Pipeline step finished' ErrorObj=0 InputObj=0 InputObjSpeed=0 OutputObj=0 OutputObjSpeed=0 stepName=LoadObjData stepNum=2 time='2022-08-07T14:39:38+08:00' level=info msg='Pipeline step finished' ErrorObj=0 InputObj=0 InputObjSpeed=0 OutputObj=0 OutputObjSpeed=0 stepName=UploadObj stepNum=3 time='2022-08-07T14:39:38+08:00' level=info msg='Pipeline step finished' ErrorObj=0 InputObj=0 InputObjSpeed=0 OutputObj=0 OutputObjSpeed=0 stepName=Terminator stepNum=4 time='2022-08-07T14:39:38+08:00' level=info msg='Duration: 4.687948ms' durationSec=0.004685223 time='2022-08-07T14:39:38+08:00' level=error msg='Sync Failed' status=1

  • 建议增加SCP传输文件功能 及 任务管理界面

    建议增加SCP传输文件功能 及 任务管理界面

    1、两台服务器免密传输设置后(这样就能避免web端输入服务器密码了),可以使用scp功能发送备份文件。脚本示例如下: scp -r $datepath [email protected]:/data/pgdb_backup/databack

     功能放到备份配置里面。
    

    2、任务管理界面我是截图其他软件,做个类似查看页面就行,方便运维巡检备份任务情况

  • support for pg_dump's parallel dump

    support for pg_dump's parallel dump

    如果在備份 postgresql 時,使用如下的指令 pg_dump -j 4 -F d -f out.dir dbname 由於輸出是個目錄,而不是檔案,所以回傳的檔案大小會出錯

    這是備份完成後,log 看到的樣子

    2022/12/08 17:00:40 成功备份项目: n2, 文件名: n2-2022-12-08_17_00
    2022/12/08 17:00:40 Webhook调用成功, 返回数据: {"id":"VIHfGPevC0x1","time":1670490040,"event":"message","topic":"channel","message":"n2 _Backup_成功,backup_file: n2-2022-12-08_17_00,size: 0 MB"} 
    

    可以發現 filesize 是 0 MB 但實際上備份是成功的

    請考慮看看要怎麼修改如果用 parallel dump 的話,要怎麼呈現 backup filesize ?

  • windows2012    执行备份操作。提示“执行shell的输出为空”

    windows2012 执行备份操作。提示“执行shell的输出为空”

    image

    操作系统为:windows server 2012和2016军不能使用。 备份文件软件是放在:C:\inetpub\wwwroot 单独使用:SET MYSQL_PWD=1234qwer "C:\mysql\bin\mysqldump" -h127.0.0.1 -uroot question > question-2022-09-09_06_26.sql 可以备份成功。

    但是用备份软件,提示图片错误: 2022/09/16 11:19:04 question项目将在23.7小时后运行 2022/09/16 11:19:04 正在备份项目: question ... 2022/09/16 11:19:04 执行shell的输出为空 2022/09/16 11:19:04 执行备份shell失败:

    经过观察发现,同样是在,备份文件夹(question)内没有生成shell脚本。

  • feature:关键信息加密

    feature:关键信息加密

    已经在内网使用了一段时间,很稳定,点个👍🏻。不过用的过程发现了一些可以改进的地方。

    1. 数据库备份的时候,-p123456这样的方式过于粗暴,不够安全【表面的安全都没有】,是否考虑支持用户自定的{pwd}这样的占位符占位,然后在下面添加变量的形式来支持,这个变量输入后可以是*号。
    2. AccessKeySecretKey,特别是后者,目前还是明文显示的,建议改为*号。 背后还可以自定义或者默认一个加密key,通过启动的时候传入,页面背后显示的都是加密后的字段,运行的时候,再解密一次更好。
  • postgresql 备份 不支持14.1吗

    postgresql 备份 不支持14.1吗

    2022/08/24 16:15:20 执行备份shell失败: pg_dump: error: server version: 14.1 (Debian 14.1-1.pgdg110+1); pg_dump version: 13.7 (Debian 13.7-0+deb11u1) pg_dump: error: aborting because of server version mismatch

A rudimentary go program that allows you to mount a mongo database as a FUSE file system

This is a rudimentary go program that allows you to mount a mongo database as a

Dec 29, 2021
go-fastdfs 是一个简单的分布式文件系统(私有云存储),具有无中心、高性能,高可靠,免维护等优点,支持断点续传,分块上传,小文件合并,自动同步,自动修复。Go-fastdfs is a simple distributed file system (private cloud storage), with no center, high performance, high reliability, maintenance free and other advantages, support breakpoint continuation, block upload, small file merge, automatic synchronization, automatic repair.(similar fastdfs).
go-fastdfs 是一个简单的分布式文件系统(私有云存储),具有无中心、高性能,高可靠,免维护等优点,支持断点续传,分块上传,小文件合并,自动同步,自动修复。Go-fastdfs is a simple distributed file system (private cloud storage), with no center, high performance, high reliability, maintenance free and other advantages, support breakpoint continuation, block upload, small file merge, automatic synchronization, automatic repair.(similar fastdfs).

中文 English 愿景:为用户提供最简单、可靠、高效的分布式文件系统。 go-fastdfs是一个基于http协议的分布式文件系统,它基于大道至简的设计理念,一切从简设计,使得它的运维及扩展变得更加简单,它具有高性能、高可靠、无中心、免维护等优点。 大家担心的是这么简单的文件系统,靠不靠谱,可不

Jan 8, 2023
📂 Web File Browser
📂 Web File Browser

filebrowser provides a file managing interface within a specified directory and it can be used to upload, delete, preview, rename and edit your files.

Jan 9, 2023
a tool for handling file uploads simple

baraka a tool for handling file uploads for http servers makes it easier to make operations with files from the http request. Contents Install Simple

Nov 30, 2022
A tool for moving files into directories by file extensions
A tool for moving files into directories by file extensions

The tool for moving files into directories by file extensions Example before moving structure: moving into same extension dir result: moving into diff

Dec 6, 2021
A command line tool for mainly exporting logbook records from Google Spreadsheet to PDF file in EASA format
A command line tool for mainly exporting logbook records from Google Spreadsheet to PDF file in EASA format

Logbook CLI This is a command line tool for mainly exporting logbook records from Google Spreadsheet to PDF file in EASA format. It also supports rend

Feb 6, 2022
searchHIBP is a golang tool that implements binary search over a hash ordered binary file.

searchHIBP is a golang tool that implements binary search over a hash ordered binary file.

Nov 9, 2021
A useful file search tool
A useful file search tool

go-find 花了半天时间写的一个的文件名、文件内容搜索工具,主要是为了hvv中快速发现敏感文件、配置文件等。

Sep 22, 2022
Ghostinthepdf - This is a small tool that helps to embed a PostScript file into a PDF

This is a small tool that helps to embed a PostScript file into a PDF in a way that GhostScript will run the PostScript code during the

Dec 20, 2022
A small tool for sending a single file to another machine

file-traveler A small tool for sending a single file to another machine. Build g

Dec 28, 2021
A dead simple tool to rename your files for smooth web access!

ffw - Friendly Files for the Web Easily rename files from a folder to be compatible with the web Run ffw and that's it! Installation on macOs brew tap

Jan 31, 2022
Abstract File Storage

afs - abstract file storage Please refer to CHANGELOG.md if you encounter breaking changes. Motivation Introduction Usage Matchers Content modifiers S

Dec 30, 2022
Bigfile -- a file transfer system that supports http, rpc and ftp protocol https://bigfile.site
Bigfile -- a file transfer system that supports http, rpc and ftp protocol   https://bigfile.site

Bigfile ———— a file transfer system that supports http, rpc and ftp protocol 简体中文 ∙ English Bigfile is a file transfer system, supports http, ftp and

Dec 31, 2022
Go file operations library chasing GNU APIs.
Go file operations library chasing GNU APIs.

flop flop aims to make copying files easier in Go, and is modeled after GNU cp. Most administrators and engineers interact with GNU utilities every da

Nov 10, 2022
Read csv file from go using tags

go-csv-tag Read csv file from Go using tags The project is in maintenance mode. It is kept compatible with changes in the Go ecosystem but no new feat

Nov 16, 2022
File system event notification library on steroids.

notify Filesystem event notification library on steroids. (under active development) Documentation godoc.org/github.com/rjeczalik/notify Installation

Dec 31, 2022
Pluggable, extensible virtual file system for Go

vfs Package vfs provides a pluggable, extensible, and opinionated set of file system functionality for Go across a number of file system types such as

Jan 3, 2023
An epoll(7)-based file-descriptor multiplexer.

poller Package poller is a file-descriptor multiplexer. Download: go get github.com/npat-efault/poller Package poller is a file-descriptor multiplexer

Sep 25, 2022
QueryCSV enables you to load CSV files and manipulate them using SQL queries then after you finish you can export the new values to a CSV file
QueryCSV enables you to load CSV files and manipulate them using SQL queries then after you finish you can export the new values to a CSV file

QueryCSV enable you to load CSV files and manipulate them using SQL queries then after you finish you can export the new values to CSV file

Dec 22, 2021