---
title: "Partial data dumps using Postgres Row Level Security"
description: "Postgres Row Level Security can produce a seed.sql containing only safe, non-customer rows: create a restricted `exporter` role, attach RLS select policies that filter which rows it can see, then run `pg_dump --data-only --enable-row-security` as that role."
url: "https://swe.quest/articles/partial-data-dumps-using-postgres-row-level-security-7b8cbab5206adee8"
canonical: "https://supabase.com/blog/partial-postgresql-data-dumps-with-rls"
source: "Supabase"
published: "2022-06-28"
difficulty: "medium"
kind: "How-to"
reading_minutes: 4
tags: ["postgres","privacy","identity-auth","testing"]
---

# Partial data dumps using Postgres Row Level Security

A post on [Supabase](https://swe.quest/sources/supabase.md), published 2022-06-28, 4 min read, How-to. Original: [https://supabase.com/blog/partial-postgresql-data-dumps-with-rls](https://supabase.com/blog/partial-postgresql-data-dumps-with-rls)

## Summary

Postgres Row Level Security can produce a seed.sql containing only safe, non-customer rows: create a restricted \`exporter\` role, attach RLS select policies that filter which rows it can see, then run \`pg\_dump --data-only --enable-row-security\` as that role. Example policies filter by hardcoded IDs, email domain, recency (e.g. last two months of analytics events), or an \`is\_exportable\` flag column. Alternatives include fully masked database copies (Snaplet) and copy-on-write database forking (Database Lab Engine on ZFS).

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Privacy](https://swe.quest/tags/privacy.md) (Security)
- [Identity & auth](https://swe.quest/tags/identity-auth.md) (Security)
- [Testing](https://swe.quest/tags/testing.md) (Engineering practices)

## Prerequisites

- PostgreSQL roles and grants ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))
- pg\_dump basics
- SQL ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))

## Keywords

Row Level Security, pg\_dump, PostgreSQL, Supabase, Snaplet, Database Lab Engine

## Related posts

- [Higher-level CRUD Abstraction for Postgres RLS](https://swe.quest/articles/higher-level-crud-abstraction-for-postgres-rls-90207e4bb081ead2.md): Neon · 2024-11-13 · Medium · 3 min read · PostgreSQL, Identity & auth, TypeScript
  Postgres Row-Level Security requires separate USING and WITH CHECK policies per operation, which gets repetitive for CRUD apps.
- [Modelling Authorization for a Social Network with Postgres RLS and Drizzle ORM](https://swe.quest/articles/modelling-authorization-for-a-social-network-with-postgres-rls-and-drizzle-orm-6267eb437b8171e7.md): Neon · 2024-11-11 · Medium · 8 min read · PostgreSQL, Identity & auth, TypeScript, System design
  Postgres Row-Level Security can express the full authorization model for a Twitter-like social network, defined with Drizzle ORM's crudPolicy and pgPolicy helpers and the pg\_session\_jwt extension's auth.user\_id().
- [How to Set Up Row-Level Security in Postgres Using AWS Cognito](https://swe.quest/articles/how-to-set-up-row-level-security-in-postgres-using-aws-cognito-7cb6bed6c9694d22.md): Neon · 2024-12-04 · Medium · 5 min read · PostgreSQL, Identity & auth, JavaScript, Serverless
  Postgres row-level security can be driven by AWS Cognito JWTs: a Cognito User Pool issues tokens, and Neon Authorize validates them and maps claims like \`sub\` into Postgres session variables.
- [Introducing Neon RLS: Simplifying Row-Level Security For Postgres](https://swe.quest/articles/introducing-neon-rls-simplifying-row-level-security-for-postgres-4b66d76670bb402f.md): Neon · 2024-10-30 · Medium · 6 min read · PostgreSQL, Identity & auth, Multi-tenancy, TypeScript
  Neon RLS lets Postgres row-level security policies authenticate requests with JWTs from any auth provider that exposes a JWKS URL.
- [Is Postgres RLS for Everything and Everyone?](https://swe.quest/articles/is-postgres-rls-for-everything-and-everyone-1df08667813a2c82.md): Neon · 2024-11-15 · Medium · 4 min read · PostgreSQL, Identity & auth, Multi-tenancy, Security
  Postgres row-level security is a poor fit for expressing an entire app's authorization model.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
