Staubgeborener / Klipper-Backup

Klipper-Backup is a script for manual or automated Klipper GitHub backups. It's Lightweight, pragmatic and comfortable.
https://klipperbackup.xyz
300 stars 58 forks source link

Allow to create backup in custom location #47

Closed KapJI closed 10 months ago

KapJI commented 10 months ago

Let user choose where to create backup.

Tylerjet commented 10 months ago

If you are going to want the backup folder changed I would instead change it to update backup folder not the path.

ex.)

backup_folder=${backup_folder:-"config_backup"}

that way backup_path remains the same, as we do not want a user to accidentally remove $HOME when changing that variable or you could run into issues.

then in .env.example you would have

# (Optional) Folder used for creating backup repo
#  Note: script.sh starts in $HOME which is /home/{username}/
#backup_folder="config_backup"
Tylerjet commented 10 months ago

As well there needs to be a check that the backup folder is not the root of /home/{username}/ ex.) /home/mks/. or else all of /home/mks/ files would be backed up and then deleted which would wipe out the users directory.

KapJI commented 10 months ago

I want to allow user to specify arbitrary folder even if it's not inside $HOME.

With your proposal it will be allowed anyway but in much less user friendly way. E.g. one can set backup_folder="../../tmp/var/backup". So this only makes things more complicated.

But I agree with your concern regarding removing home folder. To prevent this I added a safe guard to check if backup folder is either empty or contains only .git folder.

Staubgeborener commented 10 months ago

Thank you very much for the idea and for providing the code. I am really grateful for any help here.

In this case, however, we do not (currently) need this feature. Firstly, this feature is not really necessary on regular klipper devices. Secondly, this opens too many points for problems in the current phase. The third (and most important point) is, that in the current planning this might not be compatible with a KIAUH collaboration because of reasons.

We will come back to the idea and therefore to you and the code. But I can't promise anything as things stand today.