fkie-cad / FACT_core

Firmware Analysis and Comparison Tool
https://fkie-cad.github.io/FACT_core
GNU General Public License v3.0
1.24k stars 225 forks source link

How to import/export firmware database between FACT instances? #1250

Closed ankien closed 2 weeks ago

ankien commented 2 months ago

The FACT version you are using

4.1

Your question

Hello,

I have an instance of FACT running on a server VM that due to unrelated issues, is not viable to run on anymore. Is there a way to transfer all firmware files and their analysis from that instance to another machine running FACT (preferably a method using the command line)? Or would I be better off uploading all firmware files again to the new instance?

Thanks

jstucke commented 2 months ago

Though I have not tried it, it should be possible. There are three directories that you need to save:

It is also possible to backup and restore the postgres DB with CLI tools: https://www.postgresql.org/docs/current/backup-dump.html

dorpvom commented 2 months ago

Hi, just for reference: The import / export topic is not new. We haven't yet had a great idea how to solve this. So it remains ..

ankien commented 2 months ago

Though I have not tried it, it should be possible. There are three directories that you need to save:

* The config folder of FACT (only if you changed the configuration, especially passwords)

* the folder `/media/data/fact_fw_data/` (which contains all files)

* the postgres data folder `/var/lib/postgresql/14/main/` (which contains all analysis results and meta data)
  The best way to do this would probably be to copy the FACT folder, reinstall FACT (first pre_install.sh, then install.py) and then copy over all the data.

It is also possible to backup and restore the postgres DB with CLI tools: https://www.postgresql.org/docs/current/backup-dump.html

So I tried to do this, but when I restart FACT with the data, I get a bunch of SQL errors that look like to this:

psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: could not open file "base/16385/2601": Permission denied

Looked up similar errors online and I presume this might be fragments from from unfinished analysis, or is it something else?

jstucke commented 2 months ago

could not open file "base/16385/2601": Permission denied

That sounds to me like you need to do a sudo chown -R postgres:postgres /var/lib/postgresql/ because the postgres process runs under its own user and is not the owner of the newly copied files.

jstucke commented 2 months ago

So... did it work?