1
0
Fork 0
mirror of https://github.com/pawelmalak/flame.git synced 2025-07-19 03:29:37 +02:00
flame/db/utils/backupDb.js

22 lines
440 B
JavaScript
Raw Normal View History

const fs = require('fs');
2021-11-13 23:28:43 +01:00
const { slugify } = require('./slugify');
const backupDB = () => {
if (!fs.existsSync('data/db_backups')) {
fs.mkdirSync('data/db_backups');
}
2021-11-13 23:28:43 +01:00
const slug = slugify();
const srcPath = 'data/db.sqlite';
const destPath = `data/db_backups/${slug}`;
if (fs.existsSync(srcPath)) {
if (!fs.existsSync(destPath)) {
fs.copyFileSync(srcPath, destPath);
}
}
};
module.exports = backupDB;