# Online Archive

## Steps

1. Atlas UI: cluster, Online Archive, Add Archive. Pick the database and collection.
2. Define the archive rule: a date field and an age threshold (e.g. archive documents where `createdAt` is older than 180 days). Use a custom criteria query for more complex rules.
3. Choose the schedule and the partition fields if you want them.
4. Let the first run complete, then check the archived count against your expectation.

## Rules

- The date field must exist on the documents you want archived and be a real date type. Strings that look like dates will not match.
- Archived data stays queryable through the same connection (it federates), but queries over archived data are slower. Keep hot queries on hot data by choosing the threshold from actual access patterns.
- Pausing the archive stops new data from moving; it does not bring data back. Reversing needs a restore-style operation, so get the rule right in staging first.
- Set an alert on archive job failures; a silently stuck rule means unbounded hot growth.

## Verify

Query for a document older than the threshold through the normal driver path and confirm it returns (from archive). Check hot storage stopped growing for that collection.