[TUTORIAL] Extracting and Reconstructing Proxmox config.db

flathill

New Member
May 24, 2024
3
0
1
Hello.
Maybe I am reinventing the wheel, but I am having trouble and have created a script.



Background
Proxmox stores cluster configuration in config.db, which is usually mounted under /etc/pve/ using pmxcfs (Proxmox Cluster File System). However, there are some challenges when trying to access it:

  • If the cluster is not running, /etc/pve/ is not mounted.

  • config.db is in SQLite format, making it unreadable with simple commands like cat.
To address this, I analyzed the structure of config.db and developed a script to reconstruct the filesystem from its contents.

Understanding config.db

Using sqlite3, you can inspect the database:
Code:
sqlite3 config.db ".tables"
sqlite3 config.db "SELECT * FROM tree LIMIT 5;"
The tree table contains file and directory information:
inodeparenttypenamedata
008version(NULL)
208datacenter.cfg(binary)
804virtual-guest(NULL)

  • type=4 represents directories.

  • type=8 represents files.

  • The parent column determines the directory structure.
By processing these entries, we can reconstruct the filesystem.

The Solution: A Reconstruction Script

To automate the extraction and reconstruction, I created proxmox_config_to_fs.py:
Code:
python3 proxmox_config_to_fs.py config.db -o ./reconstructed_fs --verbose --debug

  • --debug: Displays SQLite records.

  • --verbose: Shows detailed information about file and directory creation.

Conclusion

config.db provides a structured way to store the Proxmox cluster configuration, but it is not easily accessible when the cluster is down. This script allows users to extract and reconstruct the filesystem from config.db without needing a running cluster.
The script is available on GitHub:
https://github.com/flathill/Proxmox/blob/main/proxmox_config_to_fs.py
Let me know if you have any feedback or improvements!