Offline Snapshot Example
This example demonstrates how to save a database schema to a compressed offline snapshot file, and how to later reconnect to that snapshot as though it were a live database — without needing the original database to be running.
How to Run
Before running this example, complete the setup in Getting Started.
- Create an offline snapshot from the live database. Run the command:
schemacrawler \
--server postgresql \
--host postgresql \
--database schemacrawler \
--user schemacrawler \
--password schemacrawler \
--info-level maximum \
--command serialize \
--output-format ser \
--output-file share/offline.ser
This produces a compressed serialized snapshot file named “offline.ser”. For details on snapshot formats, limitations, and requirements, see SchemaCrawler Offline Catalog Snapshot.
When creating an offline database, prefer to use maximum info-level.
- Use the offline snapshot — no live database connection required. Run the command:
schemacrawler \
--server offline \
--database share/offline.ser \
--info-level standard \
--command=schema
How to Experiment
- Try other SchemaCrawler commands against the offline snapshot, such as
list,brief, ordetails:
schemacrawler \
--server offline \
--database share/offline.ser \
--info-level standard \
--command details
- Generate an HTML or text report from the offline snapshot:
schemacrawler \
--server offline \
--database share/offline.ser \
--info-level standard \
--command schema \
--output-format html \
--output-file share/output.html
- Use the offline snapshot with the grep options to search metadata without a live connection:
schemacrawler \
--server offline \
--database share/offline.ser \
--info-level standard \
--command=details \
--no-info \
--grep-columns ".*\.publisher"
- Use the offline snapshot with lint to find design issues without a live database:
schemacrawler \
--server offline \
--database share/offline.ser \
--info-level standard \
--command=lint