mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2026-04-28 11:17:38 +02:00
Data backuping every day, and on server startup
This commit is contained in:
@@ -20,6 +20,7 @@ Question Server
|
||||
module.exports = {
|
||||
ProcessIncomingRequest: ProcessIncomingRequest,
|
||||
LoadJSON: LoadJSON,
|
||||
backupData: backupData,
|
||||
}
|
||||
|
||||
const dataFile = './publicDirs/qminingPublic/data.json'
|
||||
@@ -196,3 +197,19 @@ function LoadJSON(dataFile) {
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
function backupData(data) {
|
||||
const path = './publicDirs/qminingPublic/backs/'
|
||||
utils.CreatePath(path)
|
||||
try {
|
||||
logger.Log('Backing up data...')
|
||||
utils.WriteFile(
|
||||
JSON.stringify(data),
|
||||
`${path}data_${utils.GetDateString(true)}.json`
|
||||
)
|
||||
logger.Log('Done')
|
||||
} catch (err) {
|
||||
logger.Log('Error backing up data file!', logger.GetColor('redbg'))
|
||||
console.error(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user