Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

Backup management from scenes


drboss

Question

This is modification of old scene used by many person.  I need my modification  because of many (biggest or smallest)  problem each  time when I upgrade HC2 with new firmware and the problem not happen direct after upgrade, but  hours or days after (like my last problem with corrupt z-wave databases or 503 error after restart) .

I use 2 scenes:

 

First backup-create.lua for create backup with special description. This scene is called by for ex.

Please login or register to see this link.

one time by week. In this scenes You have parameters:

  • backup_symbol = '!' -- this symbol is added on beginning of description on backup time. Scenes use this for identify autobackup and for not delete manual or upgrade time backups  (in example on attached printscreen I use ‘p’ on place of '!')
  • backup_stay = '025' -- days for store backup from 001 to 999 days (obligatory with loading zeros). When for ex. you change this parameters for one backup from 030 to 025 and after this return to 030, only this one have different store time from another backups.
  • password = 'cGR1cmJhamxvQGl0LXNlY...' -- your admin name and password coded in base64 ([email protected]:password)
  • portable = { 892 } -- id of iOS devices for popups message

 

The second scene backup-delete.lua is for management of backups. They check if exist any backups with criteria for delete (created by backup-create.lua or with special symbol in description and with put of defined time for store). After check they call function for delete backup.

In this scenes You have parameters:

  • backup_symbol = '!' -- most important to be same to backup_symbol defined in backup-create.lua
  • default_stay = 'no' -- use individual backup store time from description. Set 'yes' if you decide to ignore individual time to store backup defined in backup__store.lua and registered in backup description
  • backup_stay = '030' -- if you decide to set default_stay to 'yes' backup_delete.lua use this for check number of day after witch the backup will be delete. The backup_delete.lua use this parameter too for backup with description who start by '!' but without [NNN] for number of store day (ex. for temporary backup created manually, they be delete after this number of day)
  • password = 'cGR1cmJhamxvQGl0LXNlY...' -- your admin name and password coded in base64 ([email protected]:password)

 

Please login or register to see this attachment.

Please login or register to see this attachment.

Please login or register to see this attachment.

I have confirmation from Fibaro Support that "httpClient:request(url..." blocks handle until the scene code is over not only to end of called http work and return results. Because of this and limitation that /api/service/backups/'..id  can only be launched once at the same time to delete more than one file, you must call the external scene who delete backups.

In this case the delete function is moved from backup-delete.lua code to backup-batch.lua. All necessary parameters are passed automatically to backup-batch.lua, You only need edit parameters in backup-create.lua and backup-delete.lua.

I added for batch process NotificationService with popups on web page like in situation with to many scenes run at same time

Please login or register to see this attachment.

For restore backup when I have 503 error without chance to login I use REST client for POST http://HC2IP/api/service/backups/ with payload {"action":"restore","params":{"id":928}}. "id" I take form GET http://HC2IP/api/service/backups

 

Link for source:

Please login or register to see this link.

 

 

 

Structure of backup description used by scenes:

![025] any character/any text

! - first symbol identify backup created and used by scenes, obligatory for treatment by this two scenes

[025] - number of days for store backup, not obligatory, if not exist the backup_stay defined in backup_delete.lua are used.

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0
  • Inquirer
  • example of working batch for delete old backups:

    Please login or register to see this attachment.

     

    if you change in "Backup - delete" scene:

    local backup_symbol = '!' to local backup_symbol = '->'

    and 

    line 45 to

                if delta <= backup_stay_tmp*60*60*24 and (string.sub(backups['description'],6,7)) == backup_symbol then
    line 48 to

            elseif delta > backup_stay_tmp*60*60*24 and (string.sub(backups['description'],6,7)) == backup_symbol then

     

    the scene will be delete backup doing by HC2 on upgrade time (older than days stored in backup_stay = 60)

     

    for test scene without true delete change local dryrun = false to true 

     

    Please login or register to see this image.

    /monthly_2018_02/backup-delete-fibaro2.PNG.e829f93090ebd214a6f121751b86cc26.PNG" alt="backup-delete-fibaro2.PNG.e829f93090ebd214a6f121751b86cc26.PNG" />

     

    Version with modification for delete backup stored on upgrade process:

    Please login or register to see this code.

     

     

    • Thanks 1
    Link to comment
    Share on other sites

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...