I have deleted data from the root directory. How to safely restore them?

assylbek

New Member
Feb 3, 2025
4
1
1
I have a Kubernetes cluster with 1 master node and 2 worker nodes working as a virtual machines in the Proxmox VE. I am being connected to the master node server using SSH client session using Mobaxterm. Server's operating system is CentOS 8. While being in the root directory I have deleted all the data in there...

What algorithm of actions should I take?


Markdown (GitHub flavored):
[gitlab-runner@k8smaster01 java]$ id<br>uid=971(gitlab-runner) gid=971(gitlab-runner) groups=971(gitlab-runner),984(docker)<br>[gitlab-runner@k8smaster01 java]$ cd ..<br>[gitlab-runner@k8smaster01 opt]$ exit<br>logout<br>[root@k8smaster01 ~]# clear<br>[root@k8smaster01 ~]# ls<br>admin.conf       <br>'cribe configmap -n kube-system kube-proxy'<br>jmix2-base-img-Dockerfile  <br>portainer-lb.yaml   <br>values.yaml<br>admin-openrc.sh<br>cuba72-base-img-Dockerfile<br>k9s<br>scripts<br>zynd<br>admin-user.yaml<br>Downloads<br>openstack.env<br>scripts.tar.gz<br>anaconda-ks.cfg<br>dump.txt<br>portainer_agent<br>ter-info<br>[root@k8smaster01 ~]# nano admin-user.yaml<br>[root@k8smaster01 ~]# rm -rf * jmix2-base-img-Dockerfile<br>[root@k8smaster01 ~]# rm -rf * cuba72-base-img-Dockerfile<br>[root@k8smaster01 ~]# nano values.yaml<br>[root@k8smaster01 ~]# ls<br>zynd
How can I recover my data? I'm asking for your help, Please.

I have downloaded many files on my host system using Mobaxterm interface:

Markdown (GitHub flavored):
.bashrc<br>.bash_history<br>.bash_logout<br>.bash_profile<br>.cache<br>.config<br>.cshrc<br>.docker<br>.kube<br>.lesshst<br>.local<br>.mysql_history<br>.redhat<br>.ssh<br>.tcshrc<br>.viminfo<br>.vscode-server<br>.wget-hsts<br>Downloads<br>jmix2-base-img-Dockerfile  <br>cuba72-base-img-Dockerfile<br>portainer_agent<br>scripts<br>zynd
But, unfortunately, these files haven't installed:

Code:
admin.conf       <br>'cribe configmap -n kube-system kube-proxy'<br>portainer-lb.yaml   <br>values.yaml<br>admin-openrc.sh<br>k9s<br>admin-user.yaml<br>openstack.env<br>scripts.tar.gz<br>anaconda-ks.cfg<br>dump.txt<br>ter-info
1738599453961.png
 
Last edited:
You did a rm -rf * <somefilename> in the root user's home folder and therefore deleted the content of /root?
If you do not have a backup, the files and folders are gone. You do have a backup, right?
 
Yes, I deleted the content of /root directory. Unfortunately, I don't have a backup ;(
The system itself is running correctly, as the system files somehow have not gone. But I have reinstalled applications that was affected by the deletion.
Thank you for your reply!
 
In /root usually only data and some personalized configuration information of user root is stored. What you did is roughly like deleting content of a user profile. The impact of applications, which usually store their configuration in /etc or /opt or eventually /var should be minimal.
 
  • Like
Reactions: Johannes S
Easiest option would be propably to install ProxmoxVE to a VM, then do a tar -cfPf /root.tar /root on the vm. Copy /root.tar to the host, then extract root.tar with tar -xPf /root.tar to get a working root Profile back. Afterwards destroy the vm
 
@Johannes S I'll remember this just in case, but now I'll do a backup and hope it doesn't happen again. Thank you!
My description was mainly how you would get a working /root directory with the correct permissions even if you don't have a backup. With a backup of course you don't need to do such this