Save sessions in msfconsole?

Hello my friends
I’m going to summarize my question quickly and if anyone can help me thank you

I have the meterpreter working with a persistent payload, where I do the manual tests on an external network and so far everything is ok, I can restart “victim” and it returns to normal.

But if I close kali or even if I close msfconsole I can never recover the session I was in.

my msfconsole is already connected to database msf_bancodedados.yml

please if anyone can help me.

Yes, there is a way to save a session in Metasploit console. The sessions -i command can be used to interact with a specific session and sessions -l command lists all active sessions.

To save a session, first, you need to background the current session using the background command. Then, use the sessions -i <session ID> command to interact with the session you want to save.

Once you are interacting with the desired session, you can use the sessions -u <filename> command to save the session to a file. This will create a file containing all the details of the session, including the session ID, target IP address, port number, and other relevant information.

To restore the session, you need to start Metasploit console, connect to the database, and then use the sessions -r <filename> command to restore the saved session.

Note that you need to use the same Metasploit version and database for saving and restoring the session. Also, be aware that saving and restoring sessions may not work for all types of payloads or for sessions created with specific exploit modules.