ikifar2012 / remote-backup-addon

Automatically create and backup HA snapshots using SCP
30 stars 4 forks source link

It is not possible to set backup_keep_local to 'null' #81

Closed neillbell closed 1 year ago

neillbell commented 1 year ago

The documentation says: To keep no local backups set this to null then all backups created will be removed after remote transfer. It is not possible to set this value to null since that value does not match the regexp for this option. Setting it to blank results in the complaint that the option is missing.

patman15 commented 1 year ago

Hmm, you are right, this needs a fix. Try switching to YAML mode and set backup_keep_local: "" that should work.

neillbell commented 1 year ago

That works. Thanks! I can't believe I didn't try that.

ikifar2012 commented 1 year ago

Give this a try with version 2022.12.0

neillbell commented 1 year ago

It looks like the copy to the remote destination is successful, but the backup remains on HA. Also, the log shows a warning:

[08:02:03] INFO: Creating non-encrypted full backup: "ha-backup- 2022-12-30 08-02" [08:03:33] INFO: Backup created: 2c240b91 [08:03:33] INFO: Copying backup using SFTP/SCP. scp: dest open ""/storage/homeassistant/ha-backup- 2022-12-30 08-02.tar"": No such file or directory

scp: failed to upload file /backup/2c240b91.tar to "/storage/homeassistant/ha-backup- 2022-12-30 08-02.tar"

[08:03:34] WARNING: SFTP transfer failed, falling back to SCP: Invalid command line argument [08:03:36] INFO: Copying backup using rsync. [08:03:50] INFO: Backup process done!

patman15 commented 1 year ago

Can you please enable debugging and post the full log to see why the backup is not deleted? The warning is "ok", it seems your remote machine does not support SFTP but only SCP.

patman15 commented 1 year ago

Give this a try with version 2022.12.0

@ikifar2012 https://github.com/ikifar2012/remote-backup-addon/pull/83 is not the correct fix I fear. You made "null" to keep all backups so it is now identical to "all". Nevertheless, the documentation says set this to null then all backups created will be removed after remote transfer. I'll see if I can fix it if you are not faster than me. :)

ikifar2012 commented 1 year ago

Give this a try with version 2022.12.0

@ikifar2012 #83 is not the correct fix I fear. You made "null" to keep all backups so it is now identical to "all". Nevertheless, the documentation says set this to null then all backups created will be removed after remote transfer. I'll see if I can fix it if you are not faster than me. :)

My mistake, I will get to fixing it

patman15 commented 1 year ago

I suggest to change the schema to backup_keep_local: match(^(all|\d+)$) and the description (+ documentatio) to description: default is 'all', give a number for the last x backups to keep or set to 0 (zero) to immediately remove created backups after copying. Unfortunately, my code is not yet correct.

ikifar2012 commented 1 year ago

I suggest to change the schema to backup_keep_local: match(^(all|\d+)$) and the description (+ documentatio) to description: default is 'all', give a number for the last x backups to keep or set to 0 (zero) to immediately remove created backups after copying. Unfortunately, my code is not yet correct.

we could also do that, I am open to feedback

patman15 commented 1 year ago

As said, I would go for using 0. It is much more user friendly. Why would I be able to set 1, 2, 3, ... but not 0 and therefore have to use null? For me "keep local backups: 0" is much more intuitiv.

ikifar2012 commented 1 year ago

As said, I would go for using 0. It is much more user friendly. Why would I be able to set 1, 2, 3, ... but not 0 and therefore have to use null? For me "keep local backups: 0" is much more intuitiv.

I agree but I would like to avoid breaking existing configs, maybe we can do both?

neillbell commented 1 year ago

Can you please enable debugging and post the full log to see why the backup is not deleted? The warning is "ok", it seems your remote machine does not support SFTP but only SCP.

My server definitely supports SFTP. The "Invalid command line argument" message seems to indicate that SFTP is being called incorrectly.

One thing that may be relevant is that I'm doing both remote copy and rsync.

I'm able to set the "Enable debugging" configuration, but I can't see the whole log when I access it via the web interface. The debug output is mostly the SSH output. The only thing I see that looks relevant is:

[17:23:04] INFO: Copying backup using rsync. [17:23:04] DEBUG: Syncing /config /addons /backup /share /ssl sending incremental file list backup/ backup/da81c977.tar config/home-assistant.log config/home-assistant_v2.db config/home-assistant_v2.db-shm config/home-assistant_v2.db-wal config/zigbee.db-shm config/zigbee.db-wal config/.storage/ config/.storage/auth config/.storage/core.restore_state config/node-red/ config/node-red/node-red-contrib-home-assistant-websocket.json sent 165,763,329 bytes received 152,163 bytes 12,290,036.44 bytes/sec total size is 1,024,925,431 speedup is 6.18 [17:23:17] DEBUG: Rclone disabled. [17:23:17] DEBUG: Keep all backups. [17:23:17] INFO: Backup process done! [17:23:17] DEBUG: Requested API resource: http://supervisor/core/api/events/remote_backup_status [17:23:17] DEBUG: Request method: POST [17:23:17] DEBUG: Request data: {"result":"ok","message:":"Backup ha-backup- 2023-01-05 17-21 created."} [17:23:17] DEBUG: API HTTP Response code: 200 [17:23:17] DEBUG: API Response: {"message":"Event remote_backup_status fired."}

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.