# BF.SCANDUMP

> Export a Bloom filter in chunks, to copy or back it up elsewhere.

URL: https://docs.hotkv.com/commands/bf-scandump/

```
BF.SCANDUMP key iterator
```

- Group: Bloom filter
- Complexity: O(n), n being the bytes of the chunk returned
- HotKV Cloud: all plans
- On-Premise: no license needed

`BF.SCANDUMP` returns the Bloom filter at `key` one chunk at a time, so you
can store it outside HotKV or copy it to another key or server with
[BF.LOADCHUNK](https://docs.hotkv.com/commands/bf-loadchunk/index.md).

Start with `iterator` `0`. Each reply gives the next iterator and a chunk of
binary data. Pass the iterator back to get the next chunk, and keep every
`(iterator, data)` pair. The dump is complete when the reply's iterator is `0`
(with empty data). The first chunk describes the filter; the others hold its
bits.

Do not change the filter while you dump it, or the chunks will not match.

## Return value

An array of two elements, the same in RESP2 and RESP3:

| Element | Value |
| --- | --- |
| 1 | Integer: the iterator for the next call, or `0` when the dump is complete |
| 2 | Bulk string: the chunk's binary data (empty at the end) |

Error replies: `ERR not found` when the key does not exist,
`Second argument must be numeric` for a non-integer iterator, and
`WRONGTYPE`.

## Examples

Keep passing back the iterator from the previous reply. The call that returns
iterator `0` with empty data ends the dump:

```
127.0.0.1:6379> BF.ADD visitors alice
(integer) 1
127.0.0.1:6379> BF.SCANDUMP visitors 145
1) (integer) 0
2) ""
127.0.0.1:6379> BF.SCANDUMP nosuchfilter 0
(error) ERR not found
```

## Compatibility

Same command flow as `BF.SCANDUMP` in RedisBloom. The chunk format is HotKV's
own: load HotKV dumps into HotKV, not into RedisBloom, and the other way
around.

## See also

[BF.LOADCHUNK](https://docs.hotkv.com/commands/bf-loadchunk/index.md), [BF.INFO](https://docs.hotkv.com/commands/bf-info/index.md)