<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Sep 4, 2023 at 5:35 PM Etienne Doms <<a href="mailto:etienne.doms@gmail.com">etienne.doms@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
I have some embedded systems in the wild, not connected to anything,<br>
on which you can push a button "something went wrong, create a dump".<br>
Then later I can fetch the said dump and inspect it.<br>
<br>
I'd like to include the whole journal, for the current boot, in a<br>
binary format so that I can later do "journalctl --file<br>
path/to/journal-dump.bin" from another machine. I understand that<br>
internally everything is stored in /var/log/journal/<machine-id>, but<br>
I guess that I cannot blindly tar/cp the .journal files, since this<br>
would be racy.<br>
<br>
So, is there an API to safely dump a big ".journal" file containing a<br>
snapshot of "journalctl -b"? I could not find anything in the<br>
documentation, sorry in advance if I missed something obvious.<br></blockquote><div><br></div><div>Run `journalctl --rotate` (or send a SIGUSR2). All "rotated" .journal files (containing an '@' in their name) are offline and can be copied.<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

For now I just dump it with "-o json" which is fine, but then I cannot<br>
feed another journalctl with the given json, and need to do manual<br>
filtering.</blockquote><div><br></div><div>If you dump with `-o export` instead (or convert the JSON to the export format), you can later feed the dump into systemd-journal-remote(8) (which is somewhere in /lib/systemd) to import it back into a .journal file.</div></div><br><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr">Mantas Mikulėnas</div></div></div>