Restoring .kodi after mv command

Hi everyone!

After having my Rpb3 being stuck in a boot loop (with the sad face), which wouldn’t get any further than the Splash screen, I followed the commonly given advice, switched over to the command line and did a backup on the .kodi directory (just in case) to reinstall the mediacenter.

sudo systemctl stop mediacenter
sudo cp -r /home/osmc/.kodi /home/osmc/kodi.backup
sudo apt-get update
sudo apt-get install --reinstall rpb2-mediacenter-osmc

All commands worked out perfectly, the re-installation went through however after rebooting the boot loop remained.

I then proceeded to use

sudo systemctl stop mediacenter
sudo mv /home/osmc/.kodi /home/osmc/kodi2

in order have a clean slate.

After sudo systemctl start mediacenter it booted up with default settings. I rebooted once more and accessed the device now more comfortably via SSH and saw that the boot loop was created by a faulty profiles.xml (with 0KB). I deleted the file from the backup.

Now that I had found the culprit, my intention was it to restore the backup (with the deleted profiles.xml).

sudo systemctl stop mediacenter
sudo cp -r /home/osmc/kodi.backup/* /home/osmc/.kodi/
sudo systemctl start mediacenter

All data copied over successfully in its place. After rebooting, I could verify that all data was there, some Kodi settings that I checked over briefly seemed correct and restored, but somehow Addons were not registered (the log mentioned all addons as installed and didn’t throw any error, though). Addons and repos were not installed and ready to use. When trying to install some files for my lightpack, I received a

Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)

which I resolved using

sudo rm /var/lib/dpkg/lock

Also I deleted the /home/osmc/.kodi/userdata/Database/Addons27.db.

Now my question is, where did I go wrong in terms of restoring the .kodi directory? Are different steps necessary or are there perhaps different reasons, why stuff doesn’t seem to be there, even though it is there? Does this have something to do with the ownership of directories?

Any thoughts and help would be appreciated!

Since you know exactly what the issue is I’d ditch the new default Kodi folder you have created and restore the backup folder you made and then correct the issue.

sudo systemctl stop mediacenter
mv /home/osmc/.kodi home/osmc/kodijunk
mv /home/osmc/kodi2 /home/osmc/.kodi

Then correct the issue with profiles.xml
Then either start Kodi again or simply reboot.

If everything works ok then you can probably delete the kodijunk folder and also the kodi.backup folder

Why “sudo mv” when you are working with folders that are owned and should remain owned by osmc user?

1 Like

Very good point. I’ve amended my post.

Sorry for replying so late and thank you so much for helping me out. Since this OSMC was not at my home place, I wasn’t able to react immediately and try out your suggestions.

To sum up, I did exactly as you told me so and it made total sense now that you pointed it out (previously I was working on this device until 5am and I guess my brain just didn’t see the obvious anymore).
Weirdly enough, it didn’t help and OSMC seemed to have all data there, but somehow it didn’t seem registered. Permissions and ownership were set correctly.
My next step was it then to use an old backup that I had made with the Kodi Backup addon. After using your suggested method, I was at least able to install addons again, so I installed the Kodi Backup addon and restored my old and outdated backup. It worked and I was able to use everything for about a day until the SD card crashed and reported a major corruption. S**t happens, but now at least I’m forced to start from scratch using a fresh SD card (which might have been the reason for the boot loop in the first place).
I learned a lot throughout this debugging process and I appreciate you helping me out!!