How to Automate WordPress Backups with WP-CLI and Cron is for developers, server admins, advanced site owners, and hosting teams who have SSH access. Use this method when repeatable database exports, scripted file archives, offsite syncs, and monitoring backup schedules outside wp-admin.
A good WordPress backup includes the website files and the database. The files carry themes, plugins, uploads, configuration, and custom code. The database carries posts, pages, users, settings, WooCommerce orders, booking records, form entries, menus, and plugin data. Before you change WordPress core, PHP, DNS, plugins, themes, checkout, or a page builder, make sure you know which backup contains both halves.
When this backup method makes sense
WP-CLI and server cron is a good fit when you already have that tool available and need a practical restore path. It is especially useful before updates, redesign work, hosting migrations, malware cleanup, PHP changes, database work, and plugin troubleshooting.
Before you begin
- Confirm the WordPress URL and document root so you back up the right site.
- Find the database name in
wp-config.phpor the hosting panel. - Check free disk space; many backup failures start with a full account.
- Pause risky work until the backup finishes and you can see the file.
- For stores and booking sites, note the last order, booking, or form entry before the backup.
Backup steps
- Confirm you have SSH access and WP-CLI works for the target site.
- Use wp db export to create a database SQL file in a protected backup directory.
- Archive the WordPress files or at minimum wp-content and configuration files needed for recovery.
- Move or sync the backup to offsite storage using your approved server backup process.
- Add retention so old backups are removed after a safe window.
- Log output and alert on failures instead of assuming cron always worked.
Automated backups and cron
WP-Cron is WordPress traffic-triggered scheduling. Server cron is better for predictable backup jobs because it runs on time even when the site has no visitors. Many plugins use WP-Cron internally, so monitor both layers.
For WordPress plugin backups, remember that WordPress scheduled tasks often depend on WP-Cron. WP-Cron runs when WordPress receives traffic and notices a task is due. That is fine for many small sites, but low-traffic sites can run late. For business-critical sites, pair plugin schedules with a real server cron, hosting-panel backups, or provider backups where available.
How to test restore readiness
Use wp db import for database restore when appropriate, then restore files from the matching archive. Always test commands on staging before running them against production.
Do not test your only restore for the first time during an outage. Use a staging copy, temporary subdomain, local development environment, or provider restore preview when available. After restore, check login, home page, important pages, media, forms, checkout, email delivery, permalinks, and cache behavior.
Common mistakes
- Writing backups into public_html where they can be downloaded.
- No retention, which fills the disk.
- No alerts, which hides failed backups.
- Only backing up the database when media uploads and custom code matter too.
Where to store the backup
Keep at least one copy outside the web server. Good destinations include your own Google Drive, Dropbox, OneDrive, S3-compatible storage, Backblaze B2, Wasabi, SFTP, a provider backup vault, or a secure internal backup server. The exact tool matters less than the restore test, retention policy, and separation from the production account.
Fix I.T. Phill recommendation
Use WP-CLI and server cron as one layer, not the whole plan. Keep a second backup path for important sites, especially WooCommerce, bookings, memberships, and agency-managed sites. Before major updates, take a fresh manual backup even if automatic backups are already scheduled.
Related Fix I.T. Phill guides
- Complete WordPress backup methods guide
- How to Back Up WordPress: Complete Methods Guide
- How to Back Up WordPress by cPanel Backup Wizard
- How to Back Up WordPress by cPanel File Manager and phpMyAdmin
- How to Back Up WordPress by WHM Full Account Backups
- How to Back Up WordPress by cPanel WP Toolkit
- WordPress 7.0 safe upgrade checklist
- Install essential PHP extensions for WordPress in WHM/cPanel
- Disable WordPress plugins with phpMyAdmin when wp-admin is broken
- Help4 Network hosting and website support


