npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

hongfangze-filebackup

v2.4.5

Published

comm.filebackup

Readme

文件备份

介绍

运行命令后,自动根据配置文件进行备份所有文件

开始使用

1、全局安装,可以使用命令直接运行
$ npm install hongfangze-filebackup -g
$ hfz-filebackup backup.json
// 参数含义:
// backup.json 配置文件绝对路径
// backup.json具体说明示例
{
  // 日志输出绝对路径,只需要配置一个目录,文件会自动产生,如果不配置或空,则生成在系统临时目录中
  "log": "",
  // 日志保留的文件数量,比如自己计划任务设置了每天一次,这个配置成7,则代表保留7天的。不配置代表永久保留(日志输出文件可能比较大,建议进行配置)
  "logCount": 7,
  // 需要复制的文件具体配置,每一个元素代表一个文件或目录
  "dir": [
    {
      // 需要复制的原始文件或目录的绝对路径
      "source":"/userdata/",
      // 目标文件或目录的绝对路径
      "dest":"/backup",
      // 遇到相同文件名是否覆盖
      // Y/y 强制覆盖 ; N/n 忽略存在的文件 ; A/a 通过比较2个文件一致性来决定,如果不一致,则覆盖
      // 如果启用了文件一致性比较(A),首次备份会在目标目录下生成文件元数据缓存文件,下次备份时会从元数据缓存文件中检测文件的一致性,加快检测耗时,缓存文件占用资源很小,非必要请勿删除,删除后会明显增加工具后续运行的时长
      "replace":"y",
      // 是否保持与原始目录一致(备份目的地会自动删除在原始目录不存在的文件),只有当source是一个目录时才生效
      "accordant": true,
      // 排除的目录或文件,只有当source是一个目录时才生效
      // 如果配置了一个存在的绝对路径或文件,那么这个文件或目录及子目录下的所有文件将不会被复制
      // 如果配置了一个文件名或目录名,那么需要复制的原始目录下的所有同名子目录或文件,都将不会被复制
      "exclude":["/userdata/a.txt"]
    }
  ],
}

2、普通安装,使用自己的代码进行调用函数
$ npm install hongfangze-filebackup

/**
 * 备份数据
 * @param {string} config 配置文件绝对路径
 * - 一个IIConfiguration借口格式的.json文件
 * - 具体配置参考resource下的demo
 */
export declare const backFile: (config: string) => Promise<void>;

3、全局或局部安装后,使用接口方式调用(v2.2.0后新增),可以有效实现单例备份模式,防止上一个命令还没备份完,下一个命令又开始启动。
$ 后台启动监听脚本(一个Node.js实现的HTTP服务,可以使用pm2等工具后台启动)
$ POST方式,调用接口,启动文件备份;将原来的定时命令替换成定时调用接口。
$ 具体使用,请参考下方的版本迭代记录。

版本迭代记录

2025-05-12 v2.4.5

  • 优化HTTP监听,防止多进程启动时的单例失效。
  • 优化元数据缓存逻辑,使大文件的比较速度更快,理论上在没改变文件的情况下,能瞬间比较完成。
  • 优化异常目录(一般为没有权限访问的目录)的提示。

2025-05-09 v2.4.1

  • 修复大文件一致性检测可能发生的磁盘IO异常。
  • 配置文件中的"replace"使用"a"选项时,会在目标目录下生成文件元数据缓存,加快下次文件一致性检查的速度,非必要请勿删除或随意修改该缓存文件(几乎不占用空间),删除后下次比较会明线增加比较一致性的时长。

2025-05-07 v2.4.0

  • 配置文件中的"replace"增加"a"选项,如果文件一致则跳过(等同于n),否则覆盖(等同于y)。

2025-05-06 v2.3.0

  • 配置文件增加“logCount”的配置,具体含义请见上方配置文件示例中的注解。

2025-04-27 v2.2.1

  • 配置文件增加“accordant”的配置。

  • resource下增加http-listen监听脚本,可以启动HTTP监听,然后以POST方式发送JSON数据包({"config":"json文件地址"}),进行备份脚本的运行,该方式在上一次备份未完成之前,不会再次备份;可用于定时(密集调用)时的单例模式进行备份操作。 命令示例 :

    $ pm2 install pm2-logrotate
    $ cd /volume1/web/hfz-filebackup/node_modules/hongfangze-filebackup/dist/resource/ && pm2 start http-listen.js --name hfz-filebackup -i 0 --merge-logs -l --log /volume1/web/hfz-filebackup/logs/.pm2/hfz-filebackup.log
    $ curl -X POST "http://localhost:43901" -H "Content-Type:application/json" -d "{\"config\":\"/volume1/web/hfz-filebackup/backup.json\"}"

2025-04-26 v2.1.2

  • 排除的项目支持指定某具体目录或某具体文件,也支持任何子目录下的某文件或目录。
  • 输出的日志文件增加时间。
  • 修复“排除”可能不稳定的处理。

2025-04-25 v2.0.0

  • 重新规划代码。
  • 脚本和函数分离。
  • 增加排除文件选项。

2025-04-24 v1.0.0

  • 实现文件深度复制。