nwb
Node WordPress Backup
Node WordPress Backup (nwb) is a sophisticated, modular Node.js application designed for efficient and secure WordPress site backups. Built with TypeScript, this system provides a comprehensive solution for backing up WordPress databases, uploads, and media files to secure cloud storage.

Core Features
- Database Backup: Automated MySQL database backup with configurable retention policies
- Media File Management: Intelligent backup of WordPress media files with optimization
- Upload Directory Handling: Efficient backup of WordPress uploads directory
- Incremental Backups: Only backs up files that have changed since the last backup
- Image Optimization: Automatically optimizes and resizes images during backup
- Cloud Storage Integration: Seamless integration with S3-compatible storage providers
- CLI Interface: User-friendly command-line interface for backup and restore operations
Manifest-Based Backup Strategy
The system employs a manifest-based approach for tracking file metadata, which uses:
- Incremental Backup Logic: Reduces storage requirements by comparing existing backups with current files
- Preserves file modification timestamps for accurate restoration
- Binary Serialization for efficient manifest storage
- Efficient Image Handling: Advanced image processing with smart derivative management
Architecture
Core Technologies
The application uses Commander.js to provide an intuitive CLI with multiple commands and subcommands:
- Node.js & TypeScript: Provides a robust, type-safe foundation
- AWS SDK: Integrates with S3-compatible storage for secure, scalable storage
- Sharp: High-performance image processing and optimization
- zlib: Efficient compression of backup artefacts
Modular Component Design
The system is built around specialized modules:
- Database Backup: Handles MySQL database exports with secure credential management
- Framework Backup: Manages WordPress core files and configuration
- Upload Backup: Efficiently manages user-uploaded content
- Image Backup: Implements advanced image optimization and management
Advanced Image Management
The image backup subsystem offers:
- Intelligent Deduplication: Only stores original images while tracking derivatives
- Size Capping: Automatically resizes oversized images while preserving quality
- Format Optimization: Converts between image formats for optimal storage
- Symbolic Linking: Uses symbolic links for efficient storage of WordPress image variants
Security
- Environment-Based Authentication: Secure credential management using environment variables
- Password Path Protection: Support for secure password files rather than hardcoded credentials
- Compression & Encryption: Data is compressed during transfer and storage
- Minimal Permissions: Follows principle of least privilege for database interactions