I tried looking for documentation about backing up my openHAB installation, but I only came across a tutorial for openHABian, which I don’t have, and a very long (and vehement) discussion.
But what for systems that didn’t install with openHABian? Are there any documents?
It didn’t the night from the day before yesterday to yesterday. I suppose that’s because I had put the job in the crontab of my user, instead of that of root.
I’ll check later today whether the backup succeeded last night (after moving the cronjob to my root’s crontab, obviously ).
That is just a listing of the directory where the files are.
You type ls -l (the l means long listing)
I have it set as alias in the .bashrc file in your home directory so I just type ll
It looks like this:
alias ll=‘ls -la’
Edit the file and save it and log out and then log in again and then ll will work. This saves a lot of typing.
The best terminal keyboard shortcut to use is ctrl-r This is the history of your commands.
Just press ctrl-r keys and then type in some command you previously used and it will show up in the command line. You can press enter to execute it again or use the arrow keys to change it.
My ctrl-r keys are worn out as I use it so much.
However, I wanted to go a step further, and have the script put the backup .zip files in a directory I’ve mounted onto my NAS. But that fails for some reason…
Using '/etc/openhab' as conf folder...
Using '/var/lib/openhab' as userdata folder...
Using '/usr/share/openhab/runtime' as runtime folder...
Unable to locate specified directory '/home/erik/Openhab-backups'
So I assume there’s some permission problem or something when trying to backup to a mounted directory?
Just tested both again (I copied a file manually, both via the GUI as via command line. I then checked whether these files are visible through the SMB connection to my Windows laptop, which was the case).
Using '/etc/openhab' as conf folder...
Using '/var/lib/openhab' as userdata folder...
Using '/usr/share/openhab/runtime' as runtime folder...
Using '/home/erik/Openhab-backups' as backup folder...
Writing to '/home/erik/Openhab-backups/openhab-backup-24_03_08-21_23_52.zip'...
Making Temporary Directory if it is not already there
Using /tmp/openhab/backup as TempDir
#########################################
openHAB backup script
#########################################
Copying configuration to temporary folder...
find: Failed to restore initial working directory: /home/erik/Openhab-backups: Toegang geweigerd
Toegang geweigerd = access denied (although English Linux may use different words)
totaal 36
drwxr-xr-x 2 erik erik 4096 nov 17 10:17 Afbeeldingen
drwxr-xr-x 2 erik erik 4096 nov 17 10:17 Bureaublad
drwxr-xr-x 2 erik erik 4096 mrt 5 22:50 Documenten
drwxr-xr-x 2 erik erik 4096 mrt 7 18:00 Downloads
drwxr-xr-x 2 erik erik 4096 nov 17 10:17 Muziek
drwxr-xr-x 2 erik erik 4096 nov 17 10:17 Openbaar
drwxrws--- 2 root users 4096 mrt 8 20:26 Openhab-backups
drwxr-xr-x 2 erik erik 4096 nov 17 10:17 Sjablonen
drwxr-xr-x 2 erik erik 4096 feb 16 23:20 "Video's"
erik@MinipcLG2:~$ cd /
erik@MinipcLG2:/$ ls
bin boot cdrom dev etc home lib lib32 lib64 libx32 lost+found media mnt opt proc root run sbin srv swapfile sys timeshift tmp usr var
erik@MinipcLG2:/$ sudo mkdir backup
erik@MinipcLG2:/$ ls
backup bin boot cdrom dev etc home lib lib32 lib64 libx32 lost+found media mnt opt proc root run sbin srv swapfile sys timeshift tmp usr var
erik@MinipcLG2:/$ sudo mount -t nfs 192.168.1.10:/NASErik /backup/
erik@MinipcLG2:/$ sudo /usr/bin/openhab-cli backup /backup/openhab-$(date +%A).zip
Using '/etc/openhab' as conf folder...
Using '/var/lib/openhab' as userdata folder...
Using '/usr/share/openhab/runtime' as runtime folder...
Writing to '/backup/openhab-vrijdag.zip'...
Making Temporary Directory if it is not already there
Using /tmp/openhab/backup as TempDir
#########################################
openHAB backup script
#########################################
Copying configuration to temporary folder...
Removing unnecessary files...
Zipping folder...
zip I/O error: Read-only file system
zip error: Could not create output file (/backup/openhab-vrijdag.zip)
zip failed to store a backup.
I first unmounted /backup and mounted /home/erik/Openhab-backups again, and then executed chmod 775 /home/erik/Openhab-backups. But…:
erik@MinipcLG2:~$ sudo chmod 775 /home/erik/Openhab-backups
chmod: veranderen van toegangsrechten van '/home/erik/Openhab-backups': Actie is niet toegestaan
‘Action is not permitted’…
(But regardless, if the folder is owned by root, and root has rwx permissions, should not any sudo command work?
Also, should w permission not be enough, since the command itself is not executed from the mounted folder? The command only writes to the mounted folder, no?)
I mounted /backup again and tried chmod 775 /backup. Same result…
Even stranger:
erik@MinipcLG2:~$ sudo mount -t nfs 192.168.1.10:/openHAB-backup /backup/
erik@MinipcLG2:~$ sudo chmod 775 /backup
chmod: veranderen van toegangsrechten van '/backup': Actie is niet toegestaan
erik@MinipcLG2:/$ sudo /usr/bin/openhab-cli backup /backup/openhab-$(date +%A).zip
Using '/etc/openhab' as conf folder...
Using '/var/lib/openhab' as userdata folder...
Using '/usr/share/openhab/runtime' as runtime folder...
Unable to locate specified directory '/backup'
Whereas that did do something yesterday. What’s different?
(Edit: I see what’s different. Yesterday I mounted the wrong NAS folder (NASErik instead of openHAB-backup). But why that would result in a different outcome is beyond me: their settings on my NAS server were identical!)