Journal, undo and safety

Show the history of operations

Show the five latest operations of the journal.

history limit: 5
id

Undo an operation

Undo one operation by its number.

undo 18
18

Undo with later changes included

Undo an operation together with the later operations that touched the same files.

undo 18 on_conflict: include_later
18

Undo the changes of one file

Undo the changes of one file made since an operation.

undo since: 18 paths: ["/home/user/app/src/a.go"]
/home/user/app/src/a.go

Redo an undone operation

Apply an undone operation again.

redo 18
18

Show the details of an operation

Show the files of one operation.

history 18 details: true
18

Find the operations that touched a path

Show the operations that changed a path.

history path: "/home/user/app/src/a.go"
/home/user/app/src/a.go

Pin an operation

Keep an operation in the journal for 24 hours.

journal.pin 18 until: 24h
18

Show the space of the journal

Show the free space and the space held by the journal of a volume.

journal.space
free

Show the state of the journal

Show whether the journal is on and how many operations it holds.

journal.status
journal

Set the retention limits

Keep the last 100 operations of the session.

journal.limits steps: 100
100

Purge expired entries

Remove the entries up to an operation from the journal.

journal.purge up_to: 17
17

Guard a change with a count

Stop before any change when a command targets more files than expected.

find "/home/user/app/build" glob: "**/*.o" |> assert count: 12 |> remove
E_ASSERT

Check a change with a build

Run a build after a change and roll back when it fails.

search /oldName\(/ "/home/user/app/src" glob: "**/*.go" |> replace "newName(" |> verify (run ["go", "build", "./..."] cwd: "/home/user/app" |> assert exit_code: 0)
newName

List the operations that were only partly undoable

List the operations whose changes are only partly kept in the journal.

history state: partial limit: 10
partial

List the operations that were undone

List the operations that were undone and can be redone.

history state: undone
undone

List the operations that removed files

List the operations that deleted at least one file.

history deleted: true limit: 20
id

Undo every operation back to a point

Undo all operations newer than operation 12, latest first, in one transaction.

undo to: 12
12

Undo operations of all sessions

Undo the operations of every session that are newer than operation 12.

undo to: 12 all_sessions: true
12

Undo what is possible and report the rest

Undo the files of an operation that are not touched by later changes and report the others.

undo 18 on_conflict: partial
18

Cancel an undo on conflict

Leave all files unchanged when a later change touches a file of the operation.

undo 18 on_conflict: abort
18

Undo the changes of a file made in the last hour

Restore one file to its state of one hour ago.

undo file: "/home/user/app/src/a.go" since: ago(1h)
/home/user/app/src/a.go

Release a pinned operation

Allow the journal to release an operation that was pinned.

journal.pin 18 release: true
18

Limit the age of the journal for the account

Keep the operations of the last seven days for the current account.

journal.limits age: 7d scope: user
7d

Guard a replacement with a file count

Stop before the replacement when the search finds more than five files.

search /legacyApi/ "/home/user/app/src" |> assert paths: 1..5 |> replace "currentApi"
E_ASSERT

Source file on GitHub: docs/cookbook/journal-and-undo.md