前言

也是心血来潮写的这个项目。因为在前面白嫖的 MongoDB 就被停用过,好在备份过一次,不然评论全无了

项目地址:

已优化更新 2024-05-19

  1. 修改 workflows 文件,每隔三天运行,避免资源浪费 commit#10fc7cb
  2. 优化 json 格式,与 twikoo 导出的 json 格式一致 commit#a869f6a
  3. 添加写入文件时,文件名带日期格式输出 commit#cbbd174
  4. workflows 代码添加删除旧备份文件操作 commit#cbbd174

使用演示

  1. fork 项目

  2. comment_backups/settings/secrets/actions 填入所需变量

    变量名
    PASSWORDTwikoo 密码
    TWIKOO_URL你的 Twikoo 地址
  3. Settings -> Actions -> General 下给到读和写权限

    image-20240427092513810

  4. Run workflow 即可

    image-20240427092332594

  5. 如果 Actions 运行时没有出错,那么你的 Twikoo 评论数据就会出现在仓库内了

    image-20240427092711991

  6. Actions 每隔三天运行一次,避免没必要的资源浪费!

导入数据

代码已更新优化,现在直接把仓库里的 twikoo-comment.json 下载到本地之后,到 Twikoo 管理面板导入即可,源系统选择 Twikoo

下面的步骤不用看了

  1. 先把仓库里的 twikoo-comment.json 下载到本地,然后去 【Json.cn】进行格式化

  2. 格式化之后按要求删除

    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
    -- {
    -- "code": 0,
    -- "data":
    [{
    "_id": "xxx",
    "nick": "xxx",
    "mail": "xxx@qq.com",
    "ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.80 Safari/537.36",
    "link": "xxx",
    "master": false,
    "comment": "xxx",
    "url": "/link/",
    "created": xxx,
    "updated": xxxxxx,
    "href": "https://blog.imzjw.cn/link/"
    },
    {
    "_id": "xxx",
    "uid": "xxx",
    "nick": "xxx",
    "mail": "xxx",
    "mailMd5": "xxx",
    "link": "https://blog.imzjw.cn/",
    "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36",
    "ip": "xxx.xxx.xxx.xxx",
    "master": true,
    "url": "/posts/8f9a47ec/",
    "href": "https://blog.imzjw.cn/posts/8f9a47ec/#post-comment",
    "comment": "<p>xxx,xxx</p>\n",
    "pid": "xxx",
    "rid": "xxx",
    "isSpam": xxx,
    "created": xxx,
    "updated": xxx
    }
    ]
    --}

    完整格式语法如下:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    [{
    "_id": "xxx",
    "nick": "xxx",
    "mail": "xxx",
    "ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.80 Safari/537.36",
    "link": "xxx",
    "master": false,
    "comment": "xxx",
    "url": "/link/",
    "created": 1602937777006,
    "updated": 1602937781775,
    "href": "https://blog.imzjw.cn/link/"
    },
    {

    }
    {

    }
    ...
    ]
  3. 之后即可在 Twikoo 管理面板的导入处进行导入,源系统选择 Twikoo(JSON)