1
0

fix: upload stuck in src/dump.ts

This commit is contained in:
alikia2x (寒寒) 2026-01-09 04:02:13 +08:00
parent baeee04ffb
commit 51ef6780a6
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG Key ID: 56209E0CCD8420C6
2 changed files with 10 additions and 5 deletions

View File

@ -14,6 +14,7 @@
<file url="file://$APPLICATION_CONFIG_DIR$/consoles/db/0d2dd3d3-bd27-4e5f-b0fa-ff14fb2a6bef/console_5.sql" value="0d2dd3d3-bd27-4e5f-b0fa-ff14fb2a6bef" />
<file url="file://$APPLICATION_CONFIG_DIR$/consoles/db/0d2dd3d3-bd27-4e5f-b0fa-ff14fb2a6bef/console_6.sql" value="0d2dd3d3-bd27-4e5f-b0fa-ff14fb2a6bef" />
<file url="file://$APPLICATION_CONFIG_DIR$/consoles/db/0d2dd3d3-bd27-4e5f-b0fa-ff14fb2a6bef/console_7.sql" value="0d2dd3d3-bd27-4e5f-b0fa-ff14fb2a6bef" />
<file url="file://$APPLICATION_CONFIG_DIR$/consoles/db/0d2dd3d3-bd27-4e5f-b0fa-ff14fb2a6bef/console_8.sql" value="0d2dd3d3-bd27-4e5f-b0fa-ff14fb2a6bef" />
<file url="file://$APPLICATION_CONFIG_DIR$/consoles/db/360f07a5-22e0-4aa5-8453-7b7e913f2fc7/console.sql" value="360f07a5-22e0-4aa5-8453-7b7e913f2fc7" />
<file url="file://$APPLICATION_CONFIG_DIR$/consoles/db/c73d5a8a-cf9a-4e08-bc75-84af9a6f1ba9/console.sql" value="c73d5a8a-cf9a-4e08-bc75-84af9a6f1ba9" />
</component>

View File

@ -41,6 +41,10 @@ const getMonthStr = (): string => {
return dayjs().format("YYYY-MM");
};
async function dump(filePath: string) {
await $`pg_dump -d ${dbUri} -Fc -n public > ${filePath}`;
}
async function runBackup() {
const dayStr = getDayStr();
const monthStr = getMonthStr();
@ -52,23 +56,23 @@ async function runBackup() {
if (!(await localDumpfile.exists())) {
logger.log(`Creating dump ${localDumpfile.name}...`);
const cmd = $`pg_dump -d ${dbUri} -Fc -n public > ${filePath}`;
await cmd;
await dump(filePath);
}
const monthlyBackupFile = s3.file(`dump/monthly/${monthStr}`);
if (!(await monthlyBackupFile.exists())) {
const f = Bun.file(filePath);
logger.log(`Uploading ${filePath} to ${monthlyBackupFile.name}`);
await monthlyBackupFile.write(localDumpfile);
await monthlyBackupFile.write(f);
}
const dailyBackupFile = s3.file(`dump/daily/${dayStr}`);
if (!(await dailyBackupFile.exists())) {
const f = Bun.file(filePath);
logger.log(`Uploading ${filePath} to ${dailyBackupFile.name}`);
await dailyBackupFile.write(localDumpfile);
await dailyBackupFile.write(f);
}
}