Accidentally deleted all files in /var/log/* ... how to fix yunohost?

What type of hardware are you using: Old laptop or computer
What YunoHost version are you running: yunohost: repo: stable version: 12.1.32.1
How are you able to access your server: SSH

Describe your issue

I was running out of space on my server, so I (regretably) deleted everything in /var/log … thinking that was temporary and not needed

now yunohost web admin interface is giving a 502 error, and other apps are also not working

I then tried to touch and create different files and folders in logs. I was able to get nginx to run again, as well as fail2ban … but still yunohost web admin interface gives a 502

I know I should not have done this … was a mistake… but now that I did, how can I restore things?

I have backups of apps and system via borgbase… but im not sure how to restore things from this state without the web admin interface…

Share relevant logs or error messages

none

It’s gonna be a mess but the rule of thumb is that a 502 error = the corresponding service is not running = you should check systemctl status yunohost-api (in the case of yunohost) and journalctl -u yunohost-api --no-pager --no-hostname -n 30

1 Like

yunohost-api is running according to systemctl and has no noticeable logs

root@b1:/home/trestore# journalctl -u yunohost-api --no-pager --no-hostname -n 30
Nov 10 22:43:36 systemd[1]: Started yunohost-api.service - YunoHost API Server.
Nov 10 22:54:21 systemd[1]: Stopping yunohost-api.service - YunoHost API Server...
Nov 10 22:54:21 systemd[1]: yunohost-api.service: Deactivated successfully.
Nov 10 22:54:21 systemd[1]: Stopped yunohost-api.service - YunoHost API Server.
Nov 10 22:58:57 systemd[1]: Started yunohost-api.service - YunoHost API Server

the 502 specifically says "[GET] “https://b1.commoninternet.net/yunohost/portalapi/public”: 502 "

if that gives a hint?

Didn’t test it but you can try

Hello @notplants
Check yunohost-portal-api service log (journalctl) : it should complain about a problem with a log file.
If so, try creating yunohost-portalapi.log in /var/log and then restart yunohost portal api

thank you @otm33 ! I did not realize there were additional yunohost services besides yunohost-api

restoring the log for yunohost-portal-api with proper permissions fixed the service, and it is running again and I can access the web admin interface again, thank you !

there are still some apps that are not running, but I can probably go through them and re-add the logs

basically for each service I run systemctl cat service, look at what user it is, I look at what logs it specifies, and then I mkdir -p logfolderpath and touch logpath and chown user:user logpath (or if there is a folder chown -R user:user logfolderpath)

Or you may try by force upgrade those apps to (hopefully) regenerate their logs conf

1 Like

thank you @Tho – I was also able to use this to quickly restore some apps too