TRACE-CMD-RESTORE(1)

๐Ÿ’… trace-cmd-restore(1) โ€” the libtracefs manual, but make it make sense

okay so bestie, this one's from the libtracefs manual set and it's genuinely a lifesaver. it's trace-cmd-restore, and yes the name is lowercase in the wild but we're not doing that here ๐ŸŽ€


โœจ NAME โœจ

trace-cmd-restore โ€” restore a failed trace record. that's it. that's the whole vibe. you had a crash, the record didn't finish, and this lil icon brings it back to life ๐Ÿซถ


๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

trace-cmd restore [OPTIONS] [command] cpu-file [cpu-file ...]

๐ŸŒธ DESCRIPTION ๐ŸŒธ

so the trace-cmd(1) restore command will restore a crashed trace-cmd-record(1) file. like, imagine your record job justโ€ฆ didn't make it ๐Ÿ˜ญ if for some reason a trace-cmd record fails, it leaves behind the per-cpu data files and never creates the final trace.dat. that's the sad part. the restore command is the part where we fix it โ€” it appends those files together to create a working trace.dat file that you can actually read with trace-cmd-report(1). slay.

the way it works is: when trace-cmd record runs, it spawns off a process per CPU and writes to a per-cpu file usually called trace.dat.cpuX, where X represents the CPU number that it's tracing. if the -o option was used in the trace-cmd record, then the CPU data files will have that name instead of the trace.dat name. lowkey important to remember. and if a totally unexpected crash occurs before the tracing is finished, then the per-CPU files will still exist but there will not be any trace.dat file to read from. that's the exact moment trace-cmd restore steps in โ€” it lets you create a trace.dat file with the existing data files. main character energy fr ๐Ÿ’…


โญ OPTIONS โญ

  • -c โ€” create a partial trace.dat file from the machine, to be used with a full trace-cmd restore at another time. this option is useful for embedded devices. if a server contains the cpu files of a crashed trace-cmd record (or trace-cmd listen), trace-cmd restore can be executed on the embedded device with the -c option to get all the stored information of that embedded device. then the file created could be copied to the server to run the trace-cmd restore there with the cpu files. iconic cross-machine workflow ๐Ÿงš

if -o is not specified, then the file created will be called trace-partial.dat. this is because the file is not a full version of something that trace-cmd-report(1) could use. it's a partial, bestie, don't come for it ๐Ÿ™ˆ

  • -t tracing_dir โ€” used with -c, it overrides the location to read the events from. by default, tracing information is read from the debugfs/tracing directory. -t will use that location instead. this can be useful if the trace.dat file to create is from another machine. just tar -cvf events.tar debugfs/tracing and copy and untar that file locally, and use that directory instead. chef's kiss ๐Ÿ“
  • -k kallsyms โ€” used with -c, it overrides where to read the kallsyms file from. by default, /proc/kallsyms is used. -k will override the file to read the kallsyms from. this can be useful if the trace.dat file to create is from another machine. just copy the /proc/kallsyms file locally, and use -k to point to that file. no cap, super handy โœจ
  • -o output โ€” by default, trace-cmd restore will create a trace.dat file (or trace-partial.dat if -c is specified). you can specify a different file to write to with the -o option. name it whatever you want, live your truth ๐Ÿ’–
  • -i input โ€” by default, trace-cmd restore will read the information of the current system to create the initial data stored in the trace.dat file. if the crash was on another machine, then that machine should have the trace-cmd restore run with the -c option to create the trace.dat partial file. then that file can be copied to the current machine where trace-cmd restore will use -i to load that file instead of reading from the current system. literally the whole point of the partial file lol ๐Ÿฆ‹

๐Ÿ”ฅ EXAMPLES ๐Ÿ”ฅ

if a crash happened on another box, you could run:

$ trace-cmd restore -c -o box-partial.dat

then on the server that has the cpu files:

$ trace-cmd restore -i box-partial.dat trace.dat.cpu0 trace.dat.cpu1

and that would create a trace.dat file for the embedded box. ate. no crumbs. ๐Ÿ‘‘


๐Ÿ’œ SEE ALSO ๐Ÿ’œ

trace-cmd(1), trace-cmd-record(1), trace-cmd-report(1), trace-cmd-start(1), trace-cmd-stop(1), trace-cmd-extract(1), trace-cmd-reset(1), trace-cmd-split(1), trace-cmd-list(1), trace-cmd-listen(1)

go read those too, iykyk ๐Ÿ“š


๐ŸŽ€ AUTHOR ๐ŸŽ€

Written by Steven Rostedt, <rostedt@goodmis.org[1]> โ€” ty king ๐Ÿซถ


๐ŸŒˆ RESOURCES ๐ŸŒˆ

https://git.kernel.org/pub/scm/utils/trace-cmd/trace-cmd.git/


๐Ÿ’€ COPYING ๐Ÿ’€

Copyright (C) 2010 Red Hat, Inc. Free use of this software is granted under the terms of the GNU Public License (GPL).


๐Ÿ“ NOTES ๐Ÿ“

  1. rostedt@goodmis.org mailto:rostedt@goodmis.org

okay that's the whole page bestie, ily, go restore that crashed trace ๐Ÿ’–โœจ

this lil doc was brought to you by libtracefs, dated 03/09/2026 โ€” mwah, see u in the group chat ๐Ÿ’…

๐Ÿ“ฆ where this page comes from