Back Up MongoDB to AWS S3 on a Nightly Schedule
Every night this exports your MongoDB data, timestamps it, and uploads the snapshot to AWS S3 — so a bad edit or an outage never means lost data.
- 1
Step 1 — Schedule the backup
Add a
Schedule Triggerset to a quiet hour (e.g. 02:00). - 2
Step 2 — Export the data
Add a
MongoDBnode (or SQL query) to read the full dataset, then aCode/Convert to Filenode to serialise it to CSV/JSON. - 3
Step 3 — Upload to AWS S3
Add a
AWS S3node to upload the file into abackups/{{ $now.format('yyyy-MM-dd') }}path so snapshots never overwrite each other. - 4
Step 4 — Prune old snapshots (optional)
Add a step to delete backups older than your retention window (e.g. 30 days) so AWS S3 doesn't balloon.
Frequently asked questions
How do I restore?
Download the dated file from AWS S3 and re-import it into MongoDB. Test a restore occasionally — a backup you've never restored is a guess, not a backup.
Is the data encrypted?
AWS S3 encrypts at rest, but for sensitive data add an encryption step before upload and store the key separately.