11 lines
435 B
TypeScript
11 lines
435 B
TypeScript
// Production only: a backup of data/ once a day (checked hourly, and a
|
|
// minute after start so a restart never skips a day).
|
|
import { resolve } from 'node:path'
|
|
|
|
export default defineNitroPlugin(() => {
|
|
if (process.env.NODE_ENV !== 'production') return
|
|
const run = () => backupIfDue(resolve('data'), resolve('backups')).catch(e => console.error('[backup] failed', e))
|
|
setTimeout(run, 60_000)
|
|
setInterval(run, 60 * 60_000)
|
|
})
|