name: project-backup
description: Use for implementing and enforcing project backup safety, including mandatory backup scripts or scheduled backups, restore verification, retention policies, and pre-change backup gates.
Project Backup
Quick Index (Action-Routed)
Read First (All Actions)
MissionHard PolicyTrigger ExamplesBackup Scope ModelData ClassificationRPO/RTO Definitions (Required)
Action Modules (Read As Needed)
- Establishing backup coverage:
Mandatory Workflow (Step 1-8)Backup Script RequirementsBackup Targets and Exclusions
- Security and durability:
Encryption and Access ControlOffsite/Redundancy GuidanceMonitoring and Alerting
- Change-time protection:
Pre-Change Backup GatesRestore Runbook RequirementsVerification Checklist
Risk & Failure Handling
Common Failure ModesAnti-Patterns to AvoidThis Project: Practical Baseline
Output
Deliverable Format
Mission
Ensure every project has reliable, restorable backups before risky changes can cause data/code loss.
Hard Policy
Every project must satisfy at least one of these:
- A versioned, executable local backup script in the repository.
- A documented and verifiable scheduled backup process with restore evidence.
Preferred policy:
- Have both script-based on-demand backup and scheduled backups.
If neither exists, create one before proceeding with high-risk changes.
Compliance states:
script_only: compliantscheduled_only: compliantscript_and_scheduled: preferrednone: non-compliant (block risky changes)
Enforcement:
- if state is
none, create remediation plan immediately - risky changes remain blocked until state is compliant
Trigger Examples
Use for backup setup, backup audits, or any risky change requiring recovery guarantees.
Backup Scope Model
Define scope first. Backups that miss critical assets are not valid.
Potential assets:
- Source code and config
- Dependency lockfiles
- Environment templates (not raw secrets)
- Databases
- Media/uploads/object storage
- Build/deploy metadata
- Infra config (compose/manifests/terraform)
- Generated business-critical artifacts
Data Classification
Classify data by criticality:
Tier 1 (business critical):
- production database dumps
- customer media/assets
- payment/order records
- auth/account records
Tier 2 (operationally important):
- source code
- deployment config
- CI/CD definitions
Tier 3 (reconstructable):
- caches
- local temp artifacts
- dependency installs
Backup design must guarantee Tier 1 and Tier 2 protection.
RPO/RTO Definitions (Required)
Before finalizing backup strategy, define:
- RPO (Recovery Point Objective): maximum acceptable data loss window.
- RTO (Recovery Time Objective): maximum acceptable restore time.
Minimum recommendations for active development:
- RPO: <= 24 hours
- RTO: <= 4 hours
For high-value production data, tighten further.
Mandatory Workflow
Follow in order.
Step 1: Inventory
Create a backup inventory:
- what must be backed up
- where it lives
- how often it changes
- whether it already has backup coverage
Step 2: Gap Analysis
For each critical asset, determine:
- Is it currently backed up?
- Is backup automated?
- Is retention defined?
- Has restore been tested?
Any "no" for Tier 1 assets is a blocker for risky changes.
Step 3: Strategy Selection
Define strategy per asset:
- snapshot/archive backup
- database dump backup
- object/media sync backup
- git mirror/offsite replication
Step 4: Backup Implementation Policy Enforcement
Enforce at least one valid implementation path:
Path A: Repository backup script
- script path documented (example:
scripts/backup.sh or scripts/backup.ps1) - script executable and non-interactive by default
- timestamped output artifact
- integrity verification step
- clear exit codes
Path B: Scheduled backup process
- scheduler location documented (CI job, cron, platform scheduler, etc.)
- schedule cadence documented and within defined RPO
- job output location documented
- integrity verification documented
- restore evidence documented and current
If project is cross-platform and using Path A, provide platform-specific scripts or one portable runtime script.
Step 5: Scheduling
Define cadence appropriate to compliance state:
- If
scheduled_only or script_and_scheduled: periodic scheduled backups (daily minimum for active projects). - For all states: pre-release backups.
- For all states: pre-migration/pre-refactor backups.
Notes:
- If project is
script_only, a minimal scheduler recommendation should still be documented. - If project is
scheduled_only, include a manual "run-now" procedure in the runbook.
Step 6: Retention and Rotation
Define retention windows:
- short-term frequent backups (for quick restore)
- medium-term weekly backups
- long-term monthly backups
Example baseline:
- keep 7 daily backups
- keep 4 weekly backups
- keep 6 monthly backups
Step 7: Restore Verification
Backups are incomplete without restore testing.
Required:
- run a restore drill on representative backup
- verify data integrity and app startup against restored state
- document restore duration and issues
Step 8: Ongoing Validation
At regular intervals:
- verify backup jobs succeeded
- verify artifacts are readable
- run periodic restore drills
- rotate/expire old backups safely
Backup Script Requirements
Backup scripts should implement:
- Strict mode/safety:
- fail fast on command failure
- treat unset vars as errors
- Input parameters:
- output destination
- optional mode/profile (full/incremental)
- Timestamped output:
- backup folder/file names include UTC timestamp
- Coverage:
- include required project paths
- include DB dump command where applicable
- include media/assets sync where applicable
- Integrity:
- checksum file generation (example: sha256)
- optional archive verification step
- Logging:
- concise progress logs
- explicit success/failure summaries
- Exit semantics:
- non-zero on partial or total failure
- Security:
- never print secrets to logs
- avoid embedding credentials in script body
Backup Targets and Exclusions
Default include candidates:
- repository files
- migrations
- schema files
- docs
- runtime config templates
- DB dumps
- user media content
Default exclusions:
- dependency caches (
node_modules, .venv, build caches) - ephemeral artifacts (
.next, temp files) - sensitive local-only secrets that should be stored in secret manager
Note:
- Excluding
.env from repo is correct, but production secret values still need secure backup in a secrets system.
Encryption and Access Control
For offsite backups or sensitive data:
- encrypt backup archives at rest.
- restrict access by least privilege.
- rotate encryption keys/credentials.
- maintain auditability of who can restore.
Offsite/Redundancy Guidance
Follow 3-2-1 principle where possible:
- 3 copies of data
- 2 different media/storage types
- 1 offsite copy
Local-only backups are not sufficient for disaster scenarios.
Pre-Change Backup Gates
Before risky operations (schema migration, mass refactor, dependency major upgrade):
- run backup script (or confirm latest scheduled backup within RPO)
- verify backup artifact integrity
- confirm restore instructions exist
- proceed only after gate passes
- record backup artifact ID/hash used for this gate
Restore Runbook Requirements
Maintain a concise restore runbook that includes:
- backup artifact location
- restore commands
- DB restore sequence
- media restore sequence
- post-restore validation checklist
- expected recovery time
Verification Checklist
Use this checklist for completion:
- [ ] Critical asset inventory complete
- [ ] Gaps identified and resolved for Tier 1/Tier 2 assets
- [ ] Compliance state is
script_only, scheduled_only, or script_and_scheduled - [ ] Backup script exists OR scheduled backups are fully documented and verified
- [ ] Schedule and retention defined
- [ ] Integrity checks implemented
- [ ] Restore drill completed and documented
- [ ] Pre-change backup gate defined
- [ ] Ownership assigned for ongoing backup monitoring
Monitoring and Alerting
If automation exists, require:
- backup success/failure notifications
- alert on missed backup windows
- alert on integrity check failures
- alert on storage quota exhaustion
Common Failure Modes
- Backup job "succeeds" but excludes critical paths.
- DB dump exists but not restorable due to version mismatch.
- Media backups omit recent uploads due to wrong path filter.
- Retention policy deletes latest valid restore point.
- Backups exist but no one has tested restore.
Anti-Patterns to Avoid
- "Git is enough backup."
- Manual one-off backups with no repeatability.
- No integrity checks.
- No restore tests.
- Backups stored only on same machine/disk.
When applying this skill, produce:
- Asset inventory
- Gap analysis
- Backup implementation plan
- Script/schedule details
- Restore runbook summary
- Verification evidence and remaining risks
- compliance state and go/no-go for risky change execution
This Project: Practical Baseline
For projects like this stack (frontend/backend/media):
- back up repository (excluding heavy caches)
- back up database (dump)
- back up uploads/media paths
- run integrity hash generation
- store backup artifacts in timestamped directory
- validate with test restore on a regular cadence