chop
is an offline urbit
subcommand that truncates a pier's event log, effectively reducing the size of the pier on disk to roughly the size of its current snapshot.
Here's how it might work:
- Gracefully shutdown the ship if it's running
- Prepare for truncation
- Ensure the ship is stopped
- Ensure the snapshot is current (maybe no manual check is req'd)
- Save a copy of the current snapshot (separate from the one in
.urb/chk
)- Make a dummy/magic event instead? (probably more difficult implementation)
- Truncate
- Save the last event and current db's metadata in memory
- Move the current db file to
data.mdb.bak
- Create a new
data.mdb
file and paste in the last event and metadata
- Check the ship's functionality by booting it with
-L
(local networking only)- On success, safely move/remove/compress
data.mdb.bak
file and reboot ship on the live network - On failure, stop ship and restore old event log via
mv data.mdb.bak data.mdb
- On success, safely move/remove/compress