mirror of
https://github.com/certd/certd.git
synced 2026-04-24 04:17:25 +08:00
perf: 触发证书重新申请input变化对比规则优化,减少升级版本后触发申请证书的情况
This commit is contained in:
@@ -102,7 +102,7 @@ export class AsyncSsh2Client {
|
||||
let iconv: any = await import('iconv-lite');
|
||||
iconv = iconv.default;
|
||||
return new Promise((resolve, reject) => {
|
||||
this.logger.info(`执行命令:[${this.connConf.host}][exec]: ` + script);
|
||||
this.logger.info(`执行命令:[${this.connConf.host}][exec]: \n` + script);
|
||||
this.conn.exec(script, (err: Error, stream: any) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
@@ -274,7 +274,7 @@ export class SshClient {
|
||||
let { script } = options;
|
||||
const { connectConf } = options;
|
||||
|
||||
this.logger.info('命令:', script);
|
||||
// this.logger.info('命令:', script);
|
||||
return await this._call({
|
||||
connectConf,
|
||||
callable: async (conn: AsyncSsh2Client) => {
|
||||
|
||||
@@ -4,6 +4,8 @@ import path from 'path';
|
||||
import dayjs from 'dayjs';
|
||||
import { SshAccess, SshClient } from '../../plugin-host/index.js';
|
||||
import { AbstractPlusTaskPlugin } from '@certd/plugin-plus';
|
||||
import JSZip from 'jszip';
|
||||
import * as os from 'node:os';
|
||||
|
||||
const defaultBackupDir = 'certd_backup';
|
||||
const defaultFilePrefix = 'db-backup';
|
||||
@@ -100,16 +102,25 @@ export class DBBackupPlugin extends AbstractPlusTaskPlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
this.logger.info('当前备份方式:', this.backupMode);
|
||||
//本地压缩
|
||||
const zip = new JSZip();
|
||||
zip.file(dbPath);
|
||||
const content = await zip.generateAsync({ type: 'nodebuffer' });
|
||||
const dbZipFilename = `${this.filePrefix}.${dayjs().format('YYYYMMDD.HHmmss')}.sqlite.zip`;
|
||||
const dbZipPath = path.resolve(os.tmpdir(), dbZipFilename);
|
||||
await fs.promises.writeFile(dbZipPath, content);
|
||||
this.logger.info(`数据库文件压缩完成:${dbZipPath}`);
|
||||
|
||||
this.logger.info('开始备份,当前备份方式:', this.backupMode);
|
||||
const backupDir = this.backupDir || defaultBackupDir;
|
||||
const backupFile = `${backupDir}/${this.filePrefix}.${dayjs().format('YYYYMMDD.HHmmss')}.sqlite`;
|
||||
const backupFilePath = `${backupDir}/${dbZipFilename}`;
|
||||
|
||||
if (this.backupMode === 'local') {
|
||||
await this.localBackup(dbPath, backupDir, backupFile);
|
||||
await this.localBackup(dbPath, backupDir, backupFilePath);
|
||||
} else if (this.backupMode === 'ssh') {
|
||||
await this.sshBackup(dbPath, backupDir, backupFile);
|
||||
await this.sshBackup(dbPath, backupDir, backupFilePath);
|
||||
} else if (this.backupMode === 'oss') {
|
||||
await this.ossBackup(dbPath, backupDir, backupFile);
|
||||
await this.ossBackup(dbPath, backupDir, backupFilePath);
|
||||
} else {
|
||||
throw new Error(`不支持的备份方式:${this.backupMode}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user