ikifar2012 / remote-backup-addon

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

Error on renaming the Backup: mv: failed to access XY: Not a directory #24

Closed hendrikma closed 2 years ago

hendrikma commented 2 years ago

Hey folks,

i just installed your addon and it works fine, except one things:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00-banner.sh: executing... 
-----------------------------------------------------------
 Add-on: Remote Backup
 Automatically create and backup HA snapshots using SCP
-----------------------------------------------------------
 Add-on version: 2021.8.0
 You are running the latest version of this add-on.
 System: Home Assistant OS 6.3  (aarch64 / raspberrypi4-64)
 Home Assistant Core: 2021.9.6
 Home Assistant Supervisor: 2021.09.0
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing... 
[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
Adding SSH key
Creating local backup: "hassio-backup- 2021-09-15 18-02"
Backup created: 3868cec2
Copying 3868cec2.tar to ~/folder on 192.168.178.5 using SCP
Warning: Permanently added '192.168.178.5' (ED25519) to the list of known hosts.
Renaming 3868cec2.tar to hassio-backup- 2021-09-15 18-02.tar
mv: failed to access '/my/folder/hassio-backup- 2021-09-15 18-02.tar': Not a directory
[cmd] /run.sh exited 1
[cont-finish.d] executing container finish scripts...
[cont-finish.d] 99-message.sh: executing... 
-----------------------------------------------------------
                Oops! Something went wrong.

 We are so sorry, but something went terribly wrong when
 starting or running this add-on.

 Be sure to check the log above, line by line, for hints.
-----------------------------------------------------------
[cont-finish.d] 99-message.sh: exited 0.
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.

I am not very into python nor HA-Dev but i think there is an escaping-error in this line:

ssh remote "mv "${REMOTE_DIRECTORY}"/${slug}.tar "${REMOTE_DIRECTORY}"/\"${name}\".tar"

Any suggestions on this?

ikifar2012 commented 2 years ago

Thank you for opening this issue

I am not very into python nor HA-Dev but i think there is an escaping-error in this line:

ssh remote "mv "${REMOTE_DIRECTORY}"/${slug}.tar "${REMOTE_DIRECTORY}"/\"${name}\".tar"

I am no expert either, but I think you are right something is indeed wrong with my regex, despite me being unable to recreate your bug.

I ran that line through a regex debugger and sure enough it found some issues image

I am thinking this will be the fix:

ssh remote "mv "${REMOTE_DIRECTORY}"\/\${slug}.tar "${REMOTE_DIRECTORY}"\/\"${name}\".tar"

I will run some tests and try to have a fix out very soon

Thank you again for pointing this out, I don't think I would have been able to find this on my own

ikifar2012 commented 2 years ago

Nope I was wrong, that's not correct either

ikifar2012 commented 2 years ago

Thanks to @DubhAd (aka Tinkerer on Discord) I believe I have solved this issue, Thanks for pointing it out, I will be releasing 2021.9.0 soon, I hope to hear back to see if it solves your issue

ikifar2012 commented 2 years ago

I just noticed you have a space at the beginning of your filename, so if updating to 2021.9.0 doesn't fix it I would suggest removing that

hendrikma commented 2 years ago

I want to thank you very much for your quick response and related update last month.

Unfortunately, I still have this problem:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00-banner.sh: executing... 
-----------------------------------------------------------
 Add-on: Remote Backup
 Automatically create and backup HA snapshots using SCP
-----------------------------------------------------------
 Add-on version: 2021.9.0
 You are running the latest version of this add-on.
 System: Home Assistant OS 6.4  (aarch64 / raspberrypi4-64)
 Home Assistant Core: 2021.9.7
 Home Assistant Supervisor: 2021.09.6
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing... 
[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
Adding SSH key
Creating local backup: "hassio-backup- 2021-10-04 03-00"
Backup created: 8225ace8
Copying 8225ace8.tar to ~/backup_hassio on 192.168.178.5 using SCP
Warning: Permanently added '192.168.178.5' (ED25519) to the list of known hosts.
Renaming 8225ace8.tar to hassio-backup- 2021-10-04 03-00.tar
mv: cannot stat '~/backup_hassio/8225ace8.tar': No such file or directory
[cmd] /run.sh exited 1
[cont-finish.d] executing container finish scripts...
[cont-finish.d] 99-message.sh: executing... 
-----------------------------------------------------------
                Oops! Something went wrong.

 We are so sorry, but something went terribly wrong when
 starting or running this add-on.

 Be sure to check the log above, line by line, for hints.
-----------------------------------------------------------
[cont-finish.d] 99-message.sh: exited 0.
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.

The uploaded file is a tar archive with the name of the folder specified in the configuration:

backupmaster@Diskstation:~$ ls -l
-rw-r--r-- 1 backupmaster users 161699840 Oct  4 03:10 backup_hassio

Unbenannt

I sincerely hope that I could once again help to fix the problem.

Many greetings Hendrik

ikifar2012 commented 2 years ago

Have you checked to make sure the directory exists and your SSH user has access to write files to it?

EDIT: I see you have done that, try using the absolute path in remote directory

hendrikma commented 2 years ago

Well,

IT WORKS!

:D Thanks a lot for your immediate answers!

ikifar2012 commented 2 years ago

Glad I could help... when in doubt use absolute paths