# SAVE

> Write a snapshot of the data set to disk and reply once it is written.

URL: https://docs.hotkv.com/commands/save/

```
SAVE
```

- Group: Server
- Complexity: O(N) where N is the number of keys
- HotKV Cloud: all plans
- On-Premise: no license needed

`SAVE` writes a point-in-time snapshot of every database to the snapshot
file (`dbfilename` in `dir`) and replies when the file is complete. The
connection that sent it waits for the whole write, so on a large data set
prefer [BGSAVE](https://docs.hotkv.com/commands/bgsave/index.md), which replies at once and saves in the
background.

A successful `SAVE` updates [LASTSAVE](https://docs.hotkv.com/commands/lastsave/index.md) and resets
`rdb_changes_since_last_save` in [INFO](https://docs.hotkv.com/commands/info/index.md) `persistence`.

## Return value

| Case | Reply (RESP2 and RESP3) |
| --- | --- |
| Snapshot written | Simple string `OK` |
| A background save is running | Error `ERR Background save already in progress` |
| The file could not be written | Error `ERR Saving the snapshot failed, check the server log` |

## Examples

```
127.0.0.1:6379> SAVE
OK
127.0.0.1:6379> LASTSAVE
(integer) 1790000000
```

## Compatibility

Same replies as Redis 7 for the success case. HotKV's snapshot file format is
its own (the default file name is `dump.hkv`); see
[persistence](https://docs.hotkv.com/persistence/index.md).

## See also

[BGSAVE](https://docs.hotkv.com/commands/bgsave/index.md), [LASTSAVE](https://docs.hotkv.com/commands/lastsave/index.md),
[BGREWRITEAOF](https://docs.hotkv.com/commands/bgrewriteaof/index.md), [SHUTDOWN](https://docs.hotkv.com/commands/shutdown/index.md)