Added ability to backup remote DB

Added ability to restore DB
This commit is contained in:
Isaac Abadi
2022-04-21 19:29:50 -04:00
parent 091f81bb38
commit a288163644
19 changed files with 420 additions and 29 deletions

View File

@@ -266,13 +266,7 @@ function getCurrentDownloader() {
return details_json['downloader'];
}
async function backupLocalDB() {
const path_to_backups = path.join('appdata', 'db_backup');
fs.ensureDir(path_to_backups);
await fs.copyFile('appdata/local_db.json', path.join(path_to_backups, `local_db.json.${Date.now()/1000}.bak`));
}
async function recFindByExt(base,ext,files,result)
async function recFindByExt(base, ext, files, result, recursive = true)
{
files = files || (await fs.readdir(base))
result = result || []
@@ -281,6 +275,7 @@ async function recFindByExt(base,ext,files,result)
var newbase = path.join(base,file)
if ( (await fs.stat(newbase)).isDirectory() )
{
if (!recursive) continue;
result = await recFindByExt(newbase,ext,await fs.readdir(newbase),result)
}
else
@@ -396,7 +391,6 @@ module.exports = {
getMatchingCategoryFiles: getMatchingCategoryFiles,
addUIDsToCategory: addUIDsToCategory,
getCurrentDownloader: getCurrentDownloader,
backupLocalDB: backupLocalDB,
recFindByExt: recFindByExt,
removeFileExtension: removeFileExtension,
formatDateString: formatDateString,