Skip to content

Instantly share code, notes, and snippets.

@hartleybrody
Last active February 20, 2025 15:35
Show Gist options
  • Select an option

  • Save hartleybrody/3d9f6a6f9ea43cbf2923ee2c6e65b140 to your computer and use it in GitHub Desktop.

Select an option

Save hartleybrody/3d9f6a6f9ea43cbf2923ee2c6e65b140 to your computer and use it in GitHub Desktop.
backup a production redis URL to your local redis server (and analyze key usage)
# 1. download a copy of prod db to localhost
# connect to remote redis database and
# download a snapshot of the entire database
# to a local file on your filesystem
# via https://stackoverflow.com/a/61365048/625840
# docs https://redis.io/docs/manual/cli/#remote-backups-of-rdb-files
redis-cli -u $PROD_REDIS_URL --rdb dump.rdb
# 2. start your local redis-server using that
# rdb snapshot file as an argument
# via https://stackoverflow.com/a/71282587/625840
redis-server --dbfilename dump.rdb
# 3. BONUS! Analyze your local copy of the
# production redis database using redis-inventory
# via https://dclg.net/posts/2021-08-16---Redis-inventory/redis-inventory
# source https://github.com/obukhov/redis-inventory
docker run --rm dclg/redis-inventory inventory host.docker.internal:6379
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment