Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/backup_database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,23 @@
}
}

// Check if a backup for today already exists
function todayBackupExists(): boolean {
const todayFilename = filename(database!)

Check warning on line 99 in src/backup_database.ts

View workflow job for this annotation

GitHub Actions / test

Forbidden non-null assertion
const filePath = `${backupDir}/${todayFilename}`
return fs.existsSync(filePath)
}

// Running backups daily at 11 am local time
function startSchedule() {
// Run a backup immediately on startup if none exists for today
if (!todayBackupExists()) {
console.log('No backup found for today, starting one now...')
script()
} else {
console.log('Backup for today already exists, skipping immediate backup.')
}

cron.schedule(
'0 0 11 * * *',
() => {
Expand Down
Loading