fix: upload stuck in src/dump.ts
This commit is contained in:
parent
baeee04ffb
commit
51ef6780a6
@ -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>
|
||||
|
||||
14
src/dump.ts
14
src/dump.ts
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user