Automate data archiving in Bubble by moving old records to archive data types via scheduled backend workflows, reducing active database size for faster searches, and retrieving archived data on demand. This keeps your app performant as data grows without losing historical records.
Overview: Automating Data Archiving in Bubble
This tutorial shows you how to move old records to archive tables using scheduled backend workflows, reducing the size of your active database for faster searches and lower workload unit consumption.
Prerequisites
- A Bubble account with data that grows over time
- Understanding of Bubble data types and backend workflows
- Familiarity with scheduled workflows
- Basic knowledge of Bubble searches
Step-by-step guide
Create archive data types
Create archive data types
For each data type you want to archive, create a mirror type prefixed with Archive_. For example, Archive_Order with the same fields as Order plus an archived_date field. This keeps archived records separate from active ones, so active searches remain fast.
Expected result: Archive data types exist mirroring your active tables.
Build the archiving backend workflow
Build the archiving backend workflow
Create a backend workflow called archive_old_records. Search for records meeting your archive criteria: e.g., Orders where status = Completed and Date created < 90 days ago. For each record, create a corresponding Archive_Order record with all field values copied, set archived_date to Current date/time, then delete the original Order. Use a recursive workflow to process records in batches of 50 to avoid timeout.
Pro tip: Process in batches of 50 with a 1-second pause between batches to stay within Bubble's execution limits.
Expected result: Old records are copied to archive tables and removed from active tables.
Schedule the archiving workflow
Schedule the archiving workflow
Schedule the archive_old_records workflow to run weekly or monthly using the Schedule API workflow action. Set the scheduled date to next Sunday at 2 AM (or another low-traffic time). At the end of the workflow, schedule itself to run again in 7 days for weekly archiving. This creates a self-perpetuating schedule.
Expected result: Archiving runs automatically on a weekly or monthly schedule.
Build an archive retrieval interface
Build an archive retrieval interface
Create an admin page where staff can search archived records. Add a Repeating Group with Archive_Order as the type, with filters for date range and customer. Add a Restore button that creates a new Order from the archive record and deletes the archive copy. For automated archiving strategies with compliance requirements, consider working with RapidDev.
Expected result: Staff can search and optionally restore archived records when needed.
Complete working example
1DATA ARCHIVING — WORKFLOW SUMMARY2===================================34DATA TYPES:5 Order (active)6 - customer, amount, status, items, created_date7 Archive_Order (archive)8 - Same fields as Order9 - archived_date (date)1011BACKEND WORKFLOW: archive_old_records12 Step 1: Search for Orders13 status = Completed14 Date created < Current date - 90 days15 :items until #50 (batch size)16 Step 2: For each Order in batch:17 Create Archive_Order (copy all fields)18 Delete original Order19 Step 3: If more records exist (count > 0)20 Schedule archive_old_records again in 1 second21 Step 4: If no more records22 Schedule archive_old_records for next week2324SCHEDULE:25 Runs: weekly, Sunday 2:00 AM26 Self-scheduling: reschedules at end of run2728ARCHIVE RETRIEVAL:29 Admin page with:30 - Date range filter31 - Customer search32 - Repeating Group of Archive_Orders33 - Restore button per recordCommon mistakes when automating data archiving in Bubble.io to optimize app performance: Step-by
Why it's a problem: Deleting records without archiving them first
How to avoid: Always create the archive copy and verify it was saved before deleting the original.
Why it's a problem: Archiving too many records in a single workflow run
How to avoid: Process records in batches of 50 with recursive scheduling between batches.
Why it's a problem: Not including all fields in the archive data type
How to avoid: Mirror every field from the active data type in the archive type. Add the archived_date field as well.
Best practices
- Create archive types that mirror all fields from active types
- Process records in batches to avoid workflow timeouts
- Schedule archiving during low-traffic hours
- Archive based on clear criteria (age + status)
- Provide a retrieval interface for accessing archived data
- Test archiving on a small batch before running on full data
- Monitor database size in Settings after archiving runs
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
I am building a Bubble.io app where data grows over time and slows down searches. How do I set up automated data archiving with scheduled backend workflows to move old records to archive tables?
Set up automated data archiving. Create Archive_Order types mirroring my Order type. Build a scheduled backend workflow that moves completed orders older than 90 days to the archive in batches of 50. Add an admin page for searching archived records.
Frequently asked questions
How much data should I archive?
Archive records older than 60-90 days that are in a final status (Completed, Cancelled). Keep active and recent records in the main tables.
Will archiving reduce my workload units?
Yes. Searches on smaller tables are faster and consume fewer WUs. The improvement is most noticeable when you have thousands of records.
Can I still run reports on archived data?
Yes. Run reports against the archive tables. For combined reports, you may need to query both active and archive tables and merge results.
Can RapidDev help with database optimization?
Yes. RapidDev specializes in Bubble development and can help implement comprehensive data management strategies including archiving, optimization, and migration.
What if I need to restore archived records?
Build a restore workflow that creates a new record in the active table from the archive record, then deletes the archive copy.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation