Why a Decidim staging environment needs production data
A staging copy loaded with production data is what makes an upgrade or process rehearsal meaningful, because only real participants, proposals, authorizations and uploads expose the migrations and edge cases that an empty test install never will. It is only safe when the copy is changed on purpose before anything can reach a real participant or a real mailbox. Teams on a live Decidim platform usually need this setup before a minor version upgrade, before changing a custom module or a component that touches user data, and before enabling a new authorization flow that depends on existing census or verification records. Each of these changes can alter database structures or the way existing records are read, so a rehearsal on empty data proves very little.
The Decidim update guide asks you to back up the database before you upgrade, and the same discipline applies to every staging refresh. Before you restore production data into staging, confirm with your own team which backup is the source, how recent it must be, and who approves the copy, since the copy holds personal data for every registered participant. Plan to move one minor version at a time and to follow each release's own upgrade instructions, because some releases change database structures. Ask your implementer or internal team to document the exact order of steps so the rehearsal can be repeated on the real platform without improvisation.
Which staging copy approach fits which team
This table compares three ways to build a staging copy of a Decidim production database: a full restore with a sanitizing script, a restore into an isolated network with outbound mail blocked, and a synthetic dataset. Read each row as a trade-off between how closely staging matches production and how much personal data stays exposed.
| Approach | Best fit | Realism versus privacy exposure | What the team must provide |
|---|---|---|---|
| Full restore with a sanitizing script | Teams testing upgrades or custom modules against real data shapes and volumes | High realism, but personal data exists briefly before scrubbing, so any gap in the script leaks it | Tested sanitizing scripts for users, emails, messages and uploads, plus a restore runbook and a verification query set |
| Restore into an isolated network with no outbound mail | Teams that need production-like behavior, such as performance or a reproduction of a reported bug | Highest realism, with the largest exposure if access controls on staging are weaker than production | Network egress controls that block SMTP and third-party callbacks, staging access restricted to named staff, and encrypted storage for the copy |
| Synthetic dataset | Teams testing new components, forms, permissions or upgrade paths where data content does not matter | Lowest privacy exposure, but volumes, edge cases and legacy records may not match production | A seed script or fixture set maintained alongside the code, and an owner who keeps it aligned with new Decidim components |
| Hybrid: synthetic base with a small sanitized sample | Teams that want realistic structure for a few tests without copying whole tables | Moderate realism and moderate exposure, depending on how the sample is selected and scrubbed | Clear rules for which records are sampled, a review step before import, and a record of what was copied |
| Restore without disabling SMTP or changing addresses | Rarely appropriate; included to show the common failure | Full realism, but staging can email real participants, which is a privacy incident | Nothing acceptable; disable outbound mail and rewrite addresses before the first job runs |
| Refreshing the copy on a fixed schedule | Teams that run upgrade rehearsals or training on a stable baseline | Exposure recurs with each refresh, so the process needs repeating controls | A documented refresh procedure, an agreed refresh cadence, and deletion of the previous copy |
| Staging used for public demonstrations | Teams showing features to stakeholders | Usually poor fit, because demo access tends to widen beyond the staff who need it | Synthetic data only, separate credentials and a clear label that the environment is not production |
How to build and sanitize the copy
This sequence produces a Decidim copy of production that holds real data but cannot send mail, reach production services, or expose uploaded files to anyone outside the team. Each step ends with a check so the copy is only used once its isolation has been confirmed.
Take and verify the production backup
The platform owner or the operator with production database access takes a fresh backup of the PostgreSQL database and the uploaded files, either from the file storage or the object storage bucket. Record the time, the Decidim version and the Ruby and Node versions in use so the copy can be matched to production exactly. Restore the backup to a scratch database once, on a separate machine, to confirm it is readable. The step is done when the restore completes and the record counts for key tables such as users, proposals and comments match production at the moment of the dump.
Restore to isolated infrastructure
Create the copy on infrastructure that has no route to production, in a separate network segment or cloud account with its own credentials. Restore the database into a new PostgreSQL instance and place the uploaded files in a separate storage location or bucket that the copy alone can read. Deploy the same Decidim version as production so that database migrations and code paths match. The check is that the application starts, the database connection points only to the new instance, and no production hostnames appear in the configuration.
Point the copy at separate database and storage
Set the database host, database name, and storage settings for ActiveStorage in the copy's environment configuration so they reference only the copy's resources. Remove or replace any credentials copied from production, including secret keys, storage access keys and API tokens for third-party services, and generate new application secrets. Confirm that the copy cannot write to production storage by testing with a non-production credential that has no access to production buckets. The output is a configuration file reviewed by a second person and a log showing the copy reads and writes only its own resources.
Disable or redirect outbound SMTP
Turn off delivery to real mailboxes before the application starts serving requests. Either leave the SMTP settings empty so Decidim cannot send, or point them at a local catch-all mail capture service that stores messages for inspection. Check the global and per-organization mail settings, since a multi-organization install can hold separate SMTP values in the database. Trigger a registration, a password reset and a notification from the copy and confirm that each message is captured locally and none appears at an external address. Scheduled jobs and newsletters must be checked too, because they send mail without a user action.
Change names and email addresses in the database
Run a reviewed script against the copy's database to replace personal data in the users table and related records. Replace email addresses with unique non-deliverable values, such as a pattern on a reserved test domain, and replace names, nicknames, phone numbers and free-text personal fields with generated values. Review fields that Decidim stores in other tables, including organization contact details, notification records and any authorization data that identifies people. Confirm the result with queries that count remaining real-looking addresses and that show no two users share an address. Keep the script under version control so each refresh runs the same steps.
Make upload storage private
Change the copy's storage so that uploaded files are not publicly accessible. Remove any public-read policy on the bucket or folder, and make sure the copy serves attachments only through the application's authorization checks. Confirm that a direct URL to an uploaded file returns an access error when requested without a session, and that the copy's bucket does not appear in any public listing. Decide who on the team may view copied uploads at all, since attachments such as identity documents or private submissions may still contain personal data even after the database has been sanitized.
Confirm the copy cannot reach production services
Test the network and application boundaries from inside the copy. Verify that outbound connections to production database hosts, production storage endpoints, and production mail servers are refused. Check that social login and callback URLs registered for production do not complete from the copy, and that any webhooks, map or geocoding keys, or external API integrations point to test endpoints or are disabled. Review scheduled tasks and job queues so that no job processes production work. The step is complete when a written checklist is signed by the operator, with each boundary test recorded as passed or failed, and any failure blocks use of the copy.
Document and schedule refreshes
Record every step in a runbook so that the next refresh repeats the same sequence and the copy is not left in an unknown state. Name the person responsible for each refresh and state which team members may access the copy and its uploads. Confirm with your own security and privacy team how long copied personal data may be retained and when it must be deleted, since no retention period is set by Decidim itself. Repeat the isolation checks after every refresh, because a restore can bring back settings that were fixed in a previous copy.
Risks that make a staging copy leak participant data
A staging copy of a Decidim install holds the same participant records, uploads and credentials as production, but it runs on hosts and accounts that are often less guarded. Each risk below is a path by which a test environment reaches real people or real systems, so each one needs a control and a check before the copy receives any data.
Live SMTP sending to participants
A staging instance that still points at production SMTP can send newsletters, proposal notifications and registration emails to real participants. Disable outgoing mail at the transport level, not only in the admin panel, and route any remaining test delivery to a sink such as a local mail catcher. Check that a test registration produces no outbound message at the mail relay. Confirm the SMTP settings in the staging environment file before the first boot.
Decidim installation docsReused OAuth and social login callbacks
Social login providers such as Google or Facebook redirect users back to the host registered with the provider. If the staging host shares a client ID with production, a login attempt on staging can reach production accounts or expose tokens. Register separate OAuth applications for staging with their own callback URLs, and remove or disable production provider credentials. Check that every provider's redirect URI points only at the staging hostname.
Social providers docsPublic upload URLs
Uploaded attachments, images and exported files can be served from predictable URLs that do not require a session. Copied production uploads therefore become readable by anyone who finds the staging hostname, and search engines may index them. Keep the storage bucket or upload directory private, require authenticated access, and block indexing on the staging host. Check that a direct request to a copied upload URL returns no file without a valid session.
Copied admin accounts with working passwords
A production database copy carries every administrator, moderator and organization manager account, including password hashes that still work. An attacker who obtains the staging login, or a former employee with staging access, gains production-level privileges. Reset all passwords and invalidate sessions after the copy, anonymize or remove non-essential admin users, and rotate any API tokens stored in the database. Check that no staging account can log in with a password known to production users.
Scheduled tasks calling external services
Recurring jobs for phase changes, open data exports and notifications run from cron or a scheduler. On a copied install they can post to external dashboards, push data to partner systems, or trigger exports that reach real recipients. Disable scheduled tasks on staging or point their outbound integrations at sandbox endpoints before enabling them. Check the crontab or scheduler and the integration settings for any production hostname before the first scheduled run.
Weaker access controls on staging hosts
Staging servers are often reachable from wider networks, use default firewall rules, or skip the single sign-on and IP restrictions applied to production. Participant personal data then sits behind a weaker perimeter than the system it came from. Restrict staging to an approved network or VPN, enforce the same authentication and TLS settings as production, and keep staging on the same patch cadence. Check that the staging hostname is unreachable from outside the approved network.
How often to refresh the copy and what breaks when you do
The core trade-off is between a stale copy and a frequent refresh. A copy that is weeks or months old drifts from production in two ways: its database schema may no longer match the release you run, and its data no longer reflects what participants are doing, so upgrade and process tests lose value. A frequent refresh keeps the copy close to production but multiplies two risks: you repeat the sanitization work each time, and each restore is another chance for real participant data, uploaded files or live mail credentials to reach a place they should not. Choose a cadence based on how often you need a meaningful test, such as before each upgrade or each planned process change, and write that cadence down so nobody refreshes ad hoc.
Treat the refresh as a repeatable script, not a runbook someone follows from memory. The script should restore the latest production backup into an isolated database, run the sanitization steps (disabling SMTP, changing names and email addresses, keeping uploads private), and then fail loudly if any step is skipped. Sanitization must be re-run every time the copy is restored, because a restore overwrites the previous clean state. Confirm the exact steps and their order against your own configuration, and store the script in version control so changes to it are reviewed like any other code.
Schema is the other thing that breaks. The Decidim update documentation says to follow each release's upgrade instructions, because some changes alter database structures. If your production copy is refreshed from a backup taken on an older release, run the upgrade steps for every intervening version against the copy before you trust any result. Ask your team to record which release each refresh came from and which release the copy was upgraded to, and to rerun the refresh whenever production moves to a new minor version.
What to confirm in your environment before relying on the copy
A staging copy only tells you something about production if it matches production in the ways that matter. The items below are the points where a copy most often drifts from the live system, and each one needs a check against vendor documentation or your own setup before you rely on test results.
Exact Decidim version and branch
Your staging copy must run the same Decidim release as production, or the test proves nothing about the upgrade or process you are rehearsing. Confirm the exact tag running in production, not just the minor branch. Decidim's SECURITY.md lists 0.32.x and 0.31.x as the branches receiving security updates, so check which branch your production instance sits on and whether a newer patch is planned before your test window. Record the exact version string in the copy's runbook.
Decidim security policyRuby and Node runtime versions
Runtime mismatches cause failures that look like upgrade bugs. Compare the Ruby and Node versions in the installation and update documentation for your Decidim release against what your production hosts and container images actually run. Decidim's documentation lists different Ruby versions for each minor branch, so a staging host built from an older template can fail for reasons unrelated to your data. Confirm the versions in your image or host before the first boot.
- Documented Node line
- Node 22.14.x
Integrations holding live credentials
Copying the database copies every stored secret that lives there, including social login client secrets, API tokens for dashboards or messaging, and storage keys. Inventory every integration configured per organization and globally, then decide for each one whether staging gets a sandbox credential, a blank value, or nothing at all. Rotate or disable anything that could post to a live channel, call a live provider, or write to a live system from the copy. Treat stored credentials as production secrets until each one is replaced.
Social providers docsMaps and geocoding calls from staging
Maps and geocoding services can be called from pages that participants view, and each call may be billed, rate limited, or logged by a third party. Check whether the staging configuration points at the same map provider and API key as production, and whether any geocoding runs on import or during test scripts. Decide whether staging should use a restricted key, a mock, or a disabled map, and confirm with the provider what usage is recorded against your account. Note that participant location data in the copy may still be sent outward if this is left open.
Identity provider test logins
A copy with production user records can accept logins from real identities if the identity provider is shared between environments. Confirm whether staging uses the production identity provider, a separate realm, or local accounts, and whether callback URLs for production are registered there. Decide how testers will sign in, and whether any sanitized account is able to act as a real administrator. Check the same question for any authorization or census handler that verifies participants against an external source.
Sanitization script tested on your data
A sanitization script that works on a sample database can still miss personal data in your real records, custom fields, uploaded file names, or free-text content such as proposal bodies and comments. Run the script against a recent restore of your own production backup, then query the result for remaining real email addresses, phone numbers, and names. Repeat the check after every Decidim upgrade, because new fields and components can introduce data the script does not yet handle. Do not refresh staging on a schedule until the script passes this check.
Questions teams ask before building a Decidim staging copy
How much effort does a Decidim staging environment take to set up?
The effort depends on how closely the copy must match production and how much data must be changed before it leaves the production boundary. A minimal setup is a second Rails and PostgreSQL stack built from the same release, with a restored database and a separate file store. The larger share of work usually sits in the steps around it: disabling outbound mail, rewriting personal data, keeping uploads private, and checking that scheduled tasks and background jobs cannot reach real participants. Ask any partner to split the quote into infrastructure, data handling and verification, so you can see which part grows with your setup.
Can our own team build a Decidim staging copy without a partner?
Yes, if your team already runs Rails applications and PostgreSQL and can operate a second environment. The parts teams most often underestimate are the data rules, not the copy itself. Someone must decide which fields are personal data, which must be replaced, and which records (such as private messages or verification documents) should never be copied at all. Your team also needs a way to prove that outbound email is off and that staging cannot be reached by participants. If those skills and owners already exist, the work can stay in-house. If not, a partner can fill the gap under a written scope.
What does our organization need to provide for the staging work?
Plan to provide separate infrastructure for staging in an environment you control, read access to a recent production backup or a controlled export, and named data owners who approve sanitization rules. Operations staff must confirm network isolation, DNS and TLS for the staging hostname, and where uploads are stored. Data owners decide what counts as sensitive in participant records, verification data and attachments. Without those decisions written down, the copy either leaks personal data or becomes too damaged to test with. Confirm these inputs before any quote is accepted.
How often does a staging copy need to be refreshed, and how long does a refresh take?
The right cadence depends on how quickly your production data changes and how often you test upgrades and processes against it. Each refresh repeats the same steps: take a backup, restore it, run sanitization, reapply staging-only settings, and verify that mail and jobs are still blocked. Refresh time grows with database size, the number of organizations on the installation, and the size of the upload store. Ask for the refresh steps and the expected duration in writing, and confirm that the process can be rerun by your team without the partner.
Which factors make a Decidim staging quote go up or down?
Most of the variation comes from four things. The number of organizations hosted on one installation adds configuration and checks for each one. Integrations such as identity providers, maps, messaging or storage services each need a safe stand-in or a disabled connection on staging. Data volume affects restore time, sanitization runtime and storage. Sanitization rules determine how many fields, attachments and user-generated texts need review and how much testing is needed to show they are clean. A quote should break down these four drivers rather than give one lump figure.
What should we ask a partner to include in a staging quote?
Ask for the written scope before any figure. It should list the Decidim version and any custom modules in the copy, the production data sources, the sanitization rules and who signed them off, and how outbound email, scheduled tasks and background jobs are disabled. Ask how uploads are kept private and who can access them, which logs are kept, and how the copy is destroyed or refreshed. Request the deliverables, the verification steps you will receive as evidence, and what is one-time versus recurring. Also ask what your team must do to keep the copy usable after the engagement ends.
Does a staging copy with production data create compliance exposure?
It can, because a copy of participant data is still personal data even if it sits on a test server. Check with your data protection lead whether copying production data to staging is allowed under your records of processing and retention rules, and whether staging must meet the same access controls as production. Restrict access to named staff, log access, and avoid copying data that the purpose does not need. DeployOpen prepares systems, controls and evidence for compliance assessments, but independent auditors and certification bodies issue any audit reports or certifications.
How data moves from production to a sanitized staging copy
The copy starts with the production PostgreSQL database and the uploads store, which are captured together in one backup so they stay consistent. That backup is restored into an isolated staging network, where a sanitization step runs before the staging app is started. The trust boundary sits between production and staging: raw personal data should never cross it, and only the sanitized copy should be readable by the staging application. Confirm each hand-off in your own environment before relying on it.
Production data passes through a backup and sanitization step before staging reads it.
How the copy changes for each environment type
Public-sector teams and regulated bodies often treat any copy of participant data as a processing activity in its own right. The staging copy usually needs the same access controls, a documented legal basis for the copy, and a retention limit, even though it is not public. The safest default is to anonymize or pseudonymize personal fields before the copy leaves the production database, and to restrict who can reach the environment at all.
- Anonymize before restore: Replace names, emails, phone numbers and free-text fields in the dump, not only in the application, so raw personal data never lands on the staging host.
- Disable outbound mail completely: Confirm that SMTP settings point nowhere live and that no job can reach participants, including exports and newsletters.
- Lock down uploads: Keep attachments private, serve them only to named staff, and do not let staging storage be reachable from the public internet.
- Record the copy: Log the date, source backup, transformations applied, the person who approved the copy and the planned deletion date.
- Restrict access: Limit administrator accounts to a short named list and review it at each refresh.
Before the first refresh, ask your data protection officer whether the copy needs a separate entry in the processing register and what the retention rule for it is.
When one Decidim installation hosts several organizations, a staging copy contains data that belongs to several data owners. Anonymization rules must cover every organization, and per-organization settings such as SMTP, authorizations and hosts must be checked one by one. A problem in one organization's copy can expose another organization's participants, so the test plan should cover each tenant separately.
- Check every organization: Review the organization list in the System panel and confirm each one has the staging hostname or is deliberately left out.
- Override per-organization SMTP: Mail settings can be set per organization, so disabling only the global setting may leave a tenant still sending real messages.
- Confirm authorizations: Census handlers and SMS or identity connections for one organization must not call live services from staging.
- Decide on a subset: Copy only the organizations needed for the test, and document which were excluded and why.
- Coordinate refresh cycles: Agree with each organization's owner when refreshes happen, since upgrades apply to all tenants at once.
Ask each organization's data owner to sign off on the copy, because approval given by the platform team alone may not cover their participants.
A team testing a custom module or a community module needs realistic data volumes and component mixes, but usually does not need every participant's personal details. The main risk is that new code behaves differently with production content, for example a proposal with unusual characters or a large number of attachments. Keeping the copy functional matters more than keeping every record identical.
- Pin the module version: Record the exact module and Decidim versions in the staging build so test results can be reproduced.
- Run data migrations on the copy first: Any migration the module adds should run against the refreshed copy before production, with timings noted.
- Keep test accounts separate: Create dedicated administrator and participant accounts for testers rather than reusing production logins.
- Compare behavior with production: Check that permissions, notifications and exports match the expected result on both environments.
- Discard after testing: Remove the module's test data and any temporary configuration once the test is signed off.
Before sign-off, confirm with the module owner which production records were exercised and whether any personal data appeared in logs or test reports.
How DeployOpen scopes and delivers Decidim staging work
DeployOpen plans, implements and documents self-hosted open-source platforms inside the client's own infrastructure, and a Decidim staging environment is delivered that way: in your cloud account, data center or private network, with your team holding the access. Most engagements are fixed-scope, so the work starts only after the scope, deliverables and timelines are written down and agreed. For a staging build, the written scope should name the production sources being copied, the target staging hosts, the database and upload storage to be refreshed, and the people who approve each step.
Before any production data is copied, the team agrees the sanitization rules and access model in writing. The rules list which fields are changed (participant names, email addresses, phone numbers, addresses and any verification data), how SMTP is disabled or redirected, how uploaded files stay private and who can reach the staging admin panel. Written rules let your privacy and security reviewers check the design before anything is copied, and they give the refresh runbook a fixed reference to test against later.
DeployOpen does not publish a price list, so a quote follows from the written scope. Ask for the quote to separate the one-time build (infrastructure setup, sanitization scripts, runbook and first refresh) from recurring work such as scheduled refreshes, Decidim upgrades on staging and any retainer. Ongoing support is available as a retainer for teams that want the refresh and upgrade rehearsals run regularly rather than as one-off projects. Confirm in the quote who holds credentials, where the copies are stored and how the environment is decommissioned.

