icml
icml (Internet Computer Memory Link) is a command-line utility to download and upload canister's memory as a way to backup an SQLite database to your local drive and upload it later.
Installation
Install the tool from command line:
Note: dfx needs to be installed for the tool to work.
Download database
Expected Canister's download function signature: (offset: nat64) -> blob
This function will be called multiple times with the increasing offset until an empty blob is returned.
Upload Database
You can use icml to upload your local file into a canister
Expected Canister's upload function signature: (offset: nat64, data: blob) -> ()
This function will be called multiple times with the increasing offset until a complete file is uploaded.
Working with the snapshot memory directly
Info
Download your canister snapshot with commands dfx canister snapshot download.
Once you have access to the downloaded memory file stable_memory.bin, you can list all the virtual memories with a non-zero length.
Extract memory from a snapshot
Download your canister snapshot with commands dfx canister snapshot download.
Once you have access to the downloaded memory file stable_memory.bin, you can extract one of the virtual memories into a local file.
In this example you have an SQLite database stored inside a virtual memory 120:
Patch memory of a stable memory snapshot
In a similar fashion you can patch existing stable memory snapshot.
Note: currently patching only affects the stable memory file and will not change .json in case the stable memory file size has changed.