mirror of
https://github.com/Sebclem/hassio-nextcloud-backup.git
synced 2024-12-23 22:46:44 +01:00
🔨 Switch to partial backup #33
This commit is contained in:
parent
310ecf1c17
commit
9c08147b00
@ -89,6 +89,20 @@ function getAddonList() {
|
||||
});
|
||||
}
|
||||
|
||||
function getAddonToBackup(){
|
||||
return new Promise((resolve, reject) => {
|
||||
let excluded_addon = settingsTools.getSettings().exclude_addon;
|
||||
getAddonList().then((all_addon)=>{
|
||||
let slugs = [];
|
||||
for(let i in all_addon){
|
||||
if(!excluded_addon.includes(all_addon[i].slug))
|
||||
slugs.push(all_addon[i].slug)
|
||||
}
|
||||
resolve(slugs)
|
||||
}).catch(()=>reject());
|
||||
});
|
||||
}
|
||||
|
||||
function getFolderList(){
|
||||
return [
|
||||
{
|
||||
@ -115,6 +129,16 @@ function getFolderList(){
|
||||
]
|
||||
}
|
||||
|
||||
function getFolderToBackup(){
|
||||
let excluded_folder = settingsTools.getSettings().exclude_folder;
|
||||
let all_folder = getFolderList()
|
||||
let slugs = [];
|
||||
for(let i in all_folder){
|
||||
if(!excluded_folder.includes(all_folder[i].slug))
|
||||
slugs.push(all_folder[i].slug)
|
||||
}
|
||||
return slugs;
|
||||
}
|
||||
|
||||
function getSnapshots() {
|
||||
return new Promise((resolve, reject) => {
|
||||
@ -254,26 +278,35 @@ function createNewBackup(name) {
|
||||
statusTools.setStatus(status);
|
||||
logger.info("Creating new snapshot...");
|
||||
let token = process.env.HASSIO_TOKEN;
|
||||
let option = {
|
||||
headers: { "X-HASSIO-KEY": token },
|
||||
responseType: "json",
|
||||
timeout: create_snap_timeout,
|
||||
json: { name: name },
|
||||
};
|
||||
getAddonToBackup().then((addons)=>{
|
||||
let folders = getFolderToBackup();
|
||||
let option = {
|
||||
headers: { "X-HASSIO-KEY": token },
|
||||
responseType: "json",
|
||||
timeout: create_snap_timeout,
|
||||
json: {
|
||||
name: name,
|
||||
addons: addons,
|
||||
folders: folders
|
||||
},
|
||||
};
|
||||
|
||||
got.post(`http://hassio/snapshots/new/partial`, option)
|
||||
.then((result) => {
|
||||
logger.info(`Snapshot created with id ${result.body.data.slug}`);
|
||||
resolve(result.body.data.slug);
|
||||
})
|
||||
.catch((error) => {
|
||||
status.status = "error";
|
||||
status.message = "Can't create new snapshot (" + error.message + ")";
|
||||
status.error_code = 5;
|
||||
statusTools.setStatus(status);
|
||||
logger.error(status.message);
|
||||
reject(status.message);
|
||||
});
|
||||
|
||||
}).catch(reject);
|
||||
|
||||
got.post(`http://hassio/snapshots/new/full`, option)
|
||||
.then((result) => {
|
||||
logger.info(`Snapshot created with id ${result.body.data.slug}`);
|
||||
resolve(result.body.data.slug);
|
||||
})
|
||||
.catch((error) => {
|
||||
status.status = "error";
|
||||
status.message = "Can't create new snapshot (" + error.message + ")";
|
||||
status.error_code = 5;
|
||||
statusTools.setStatus(status);
|
||||
logger.error(status.message);
|
||||
reject(status.message);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -272,7 +272,7 @@
|
||||
M.Dropdown.init(drops, { constrainWidth: false, coverTrigger: false, alignment: 'right', onOpenStart: () => $('#setting-trigger').addClass('active'), onCloseEnd: () => $('#setting-trigger').removeClass('active') });
|
||||
|
||||
setInterval(update_status, 500);
|
||||
setInterval(updateLocalSnaps, 2000);
|
||||
setInterval(updateLocalSnaps, 5000);
|
||||
listeners();
|
||||
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user