How to Configure Elasticsearch Backup User
You set up an elasticsearch backup user by creating a custom role with snapshot permissions. Then you bind that role to a dedicated service account or API key. Many teams skip this step and use a full admin account for scheduled backups. That wide role puts every index at risk if a script leaks its key. A scoped account limits what the backup job can read or change. How to set up an elasticsearch backup user role Elasticsearch uses role-based rules to control who can run snapshots and manage
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You set up an elasticsearch backup user by creating a custom role with snapshot permissions. Then you bind that role to a dedicated service account or API key. Many teams skip this step and use a full admin account for scheduled backups. That wide role puts every index at risk if a script leaks its key. A scoped account limits what the backup job can read or change.
How to set up an elasticsearch backup user role
Elasticsearch uses role-based rules to control who can run snapshots and manage storage. A backup process needs permission to check cluster state and write data to storage. It also needs read access to the specific indices you want to save. You do not need to give this account write rights on live production data.
First, define a custom role in your cluster security settings for snapshot tasks. Grant cluster-level rights that allow the role to create, check, and delete snapshots. Next, add index-level privileges so the role can read the target data streams. If this same user must restore data later, it will need index write rights. Many teams split backup and restore into two separate roles to reduce risk.
After you save the role, create a dedicated account or generate an API key. Attach the custom backup role to that new credential and store it safe. Point your automated timer or lifecycle policy to use this key for every run. Test the setup with a single small index before you run a full backup.
Why separate snapshot creation from restore rights
A routine backup job only needs to copy existing data out to object storage. It has no reason to overwrite or delete records inside a running production cluster. When you combine backup and restore rights in one user, you raise your risk. Anyone who steals that backup key can overwrite live tables with old snapshots.
Keep the daily snapshot user limited to read and snapshot creation actions only. Create a second, locked-down role for recovery tasks when an actual outage happens. Engineers can request that recovery role only when they need to fix broken indices. This split keeps routine automation safe while leaving a clear path for emergency restores.
User Provisioning (SCIM) + Elasticsearch Security: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Where native backup roles fall short in practice
Native cluster roles do a great job of blocking unwanted index writes during backups. They decide who can log in and which high-level snapshot APIs they can call. Still, static roles cannot inspect the content of what leaves or enters the cluster. Once a user has read rights on an index, it pulls every field inside.
This gap matters when engineers run manual snapshots or inspect backup data during fixes. Static keys also sit in config files for months without expiring or rotating. If an engineer copies a backup credential to test a restore, audit logs suffer. The cluster log only shows the shared backup account name, not the real person. Teams need a way to tie every request to a real user identity. They also need controls that mask sensitive fields like emails, phone numbers, or card numbers.
Govern statements and responses across databases and APIs
Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev sits inline in the protocol beside each supported service as an open-source proxy, a sidecar for your database or API. For every query or command an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human approval.
First, hoop.dev guardrails block banned queries before they run or hold risky ones for review, and hoop.dev data masking rewrites matched sensitive values in responses in memory. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.
Frequently asked questions
Can I use an API key instead of a password for backups?
Yes, an API key is often safer for automated scripts than a user password. You can scope the key to specific snapshot roles and revoke it at any time.
Does a backup user need write access to production indices?
No, taking a snapshot only requires cluster snapshot rights and read rights on indices. You only need index write permissions when you want to restore data back.
How do I stop a backup job from reading sensitive indices?
Scope the index privileges on the backup role to specific index names or patterns. Avoid granting a wildcard rule that covers every index in the cluster.
Related guides
In this post