Backup to github - going round in circles!

Hi,

I’m trying to update my github backup of HA following the steps in https://home-assistant.io/docs/ecosystem/backup/backup_github/and am having no joy. I’m a novice with this sort of thing and it’s not very intuitive.

I have successfully completed my first commit. My issue is with the updating. I saved the gitupdate.sh script to my HA folder and amended the path as necessary. Now when I try to run it, it either fails saying command not found or if I run it with sudo it asks for my HA password which it then proceeds to tell me is wrong when I type it in! I’m assuming it is the http_password defined in the HA setup?

Can anyone point a frustrated newbie in the right direction please?

Many thanks,

Ico

I don’t use github, but asking for the HA password doesn’t seem correct at a glance. I would assume it’s your github password.

I use tortoise HG and bitbucket. Whenever you commit, it requires your username and pw for bitbucket. That is what i’m basing my comment off of.

Hope it helps.

Thanks for the reply. I’ve tried the github password and it’s rejecting that too! I’m stumped.

…so I found out that it shouldn’t need sudo to run the script. When I try to run it, it says permission denied. I’ve tried running it as the HA user in the HA directory and copying it and running it from the pi directory.

What else could be the problem? Without the ability to back up I’m running a big risk!

Many thanks

Ico

It needs to be executable - try chmod +x gitupdate.sh

did you make the script executable?

chmod +x gitupdate.sh

Looks like the script is in the pi user folder, but you are trying to run as the homeassistant user. Maybe the HA user doesn’t have execute permissions on gitupdate.sh. What are the permissions on gitupdate.sh?

a-ha! That worked, thank you so much. Shows just how much us newbies have to learn about the subtleties of this stuff!

How do you confirm your “commit message” after “STEP 3: PREPARING YOUR HOME ASSISTANT DIRECTORY FOR GITHUB”?

I know this isn’t solicited advice, but I would recommend against using this wrapper script. It isn’t saving you much, it’s skipping things you probably ought to be doing, it’s doing things you probably don’t want to do, and it’s preventing you from actually learning how to use git all the while, which is a pretty useful skill to have.

A better process for updating your git repo is to first run git status in your directory with configuration files:

% git status

Look at the files that have changed, and look at the files that aren’t under version control yet (“untracked”). Don’t blindly add everything with “git add .”, that will just cruft up your repo over time. Are there new files you want to version control? Then add them with git add . But you don’t need to version control old logs or other cruft. Keep your repo clean with only what you would need if you had to start fresh.

Then, for each file that has changed, do:

 % git diff <filename>

and look at what has actually changed. Make sure it’s a change you want to keep. Only then commit it with:

% git commit -m "describe changes" <filename>

If you have a change that’s logically coherent but spans several files, e.g., you added a new device and got it customized and into your groups, try to group those into one commit.

If you spot things that were intended to be temporary and want to “undo” the changes in that file, or you got yourself into a problem that you want to back out of, go back to your last committed version with

% git checkout <filename>

Repeat until git status is clean. Then push your repo back to github:

% git push origin master

Going through this process and learning how to use revision control tools is worth your time, especially if you want to get into any more involved scripting or programming.

5 Likes