Skip to content
Tutorials Center
My learning

Topics

Lesson 9 of 68 ยท Using the Dashboard

Backups, Updates, Maintenance Mode and .htaccess

Back up and restore a WordPress site, update core, plugins and themes safely, use maintenance mode, create and understand .htaccess, clear caches and enable a Multisite network.

Building a site is half the job. The other half is keeping it alive: restoring it after a mistake or a hack, updating software before attackers find a hole, taking it offline politely while you work, and clearing out stale caches when a change does not show. These tasks are less glamorous than writing plugins, but they decide whether a client's site is still there in two years. This lesson covers the routine: backups and restores, updates, maintenance mode, the .htaccess file, caches and enabling a Multisite network.

The runnable examples are plain PHP stand-ins that show the logic (retention rules, the maintenance flag file, a generated rewrite block); WordPress commands in code blocks are read-only. For hardening and recovery after an attack see Security Hardening, and for deployments see Testing and Deployment.

What to back up

A WordPress site is files plus a database, and a useful backup needs both:

Part Contains Size and change rate
Database (MySQL) Posts, pages, comments, users, settings, plugin data Small, changes constantly
wp-content/uploads Media library Large, grows steadily
wp-content/themes and plugins Your code and third-party code Medium, changes on updates
wp-config.php, .htaccess Configuration, secret keys Tiny, changes rarely
WordPress core Reinstallable from wordpress.org Not essential to back up

Rules that experienced administrators follow:

  • Automate it. A backup you must remember to take will be missed.
  • Frequency follows how often content changes. A shop with orders needs backups every few hours or real-time; a brochure site needs one weekly or after each edit.
  • Keep copies off the server. A backup stored on the same machine disappears with a failed disk or a hack. Send copies to Amazon S3, Google Drive, Dropbox, an SFTP server or a second hosting account.
  • Follow 3-2-1: three copies, on two kinds of storage, one off site.
  • Keep several generations (see the retention demo below). A hack discovered three weeks later is useless to repair with yesterday's already-infected backup.
  • Test the restore. A backup that has never been restored is a hope, not a backup.

Ways to take a backup

1. A plugin. The easiest route and the best for most people. Popular ones: UpdraftPlus (free, schedules to many cloud stores, restores from the dashboard), Duplicator (also good for moving a site), WPvivid, BackWPup, Jetpack Backup and BlogVault (hosted, real-time, incremental), WP Time Capsule. Install, set a schedule, choose a remote destination, choose what to include and press Backup Now for the first copy.

2. The database by hand. In phpMyAdmin select your database, choose Export and download the .sql file. On the command line:

Terminal
# read-only examples
mysqldump -u dbuser -p wordpress_db > backup-2026-03-10.sql
wp db export backup-2026-03-10.sql          # WP-CLI version

3. The files by hand. In your host's cPanel File Manager select the site folder and choose Compress, then download the ZIP; or use FTP/SFTP (a client such as FileZilla: connect with Quickconnect, then drag the wp-content folder to your computer). Over SSH: tar czf site-files.tgz public_html.

4. The host's own backup. Many hosts snapshot the site daily. Use it as an extra safety net, but do not make it the only one: check how long it is kept and whether you can download it.

Restoring

  1. Put the site into maintenance mode (below), so visitors do not write new data during the restore.
  2. Restore the database: in phpMyAdmin choose Import and pick the .sql file (or wp db import backup.sql). Big dumps may need the command line because of upload limits.
  3. Restore the files: replace wp-content (or the whole folder) with the copy.
  4. Check wp-config.php for the right database name and credentials; if the domain changed, run a search-and-replace on the database (use wp search-replace 'old.com' 'new.com' or a plugin, never a plain text replace, because WordPress stores serialized data that must keep its length prefixes).
  5. Re-save Settings > Permalinks to rebuild rewrite rules, clear caches, and test login, a post, a form and the checkout.

With UpdraftPlus the same job is Settings > UpdraftPlus Backups > Restore: pick the backup set, tick the components, click Restore. Practice on a staging copy.

PHP Backup retention: which copies to keep (stand-in)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with fgets(STDIN)), it gets the next line from this box.

A hundred daily backups shrink to eleven: recent ones for quick undo, a few weekly and monthly ones for a problem discovered late. Plugins offer the same idea as "retain this many backups".

Updating WordPress, plugins and themes

Most successful attacks use known flaws in outdated software, so updating is the main security measure.

  • Core: WordPress installs minor and security releases (6.8.1) automatically since 3.7. Major releases (6.8 to 6.9) can be applied automatically too since 5.6, or manually from Dashboard > Updates. WP-CLI: wp core update.
  • Plugins and themes: the Updates screen or the Plugins list shows pending updates and has an Enable auto-updates link for each one. WP-CLI: wp plugin update --all.
  • Manual update: download the ZIP, deactivate the plugin, replace its folder over FTP or cPanel, reactivate. Use it only when the dashboard cannot reach the update server or a premium licence is not active.
  • Translation updates arrive in the same screen.

A safe routine: take a backup first, update on a staging copy when the site matters, read the changelog for breaking changes, update one thing at a time (so you know what broke it) and test the main paths afterward (home page, a post, login, forms, checkout). Remove plugins and themes you do not use instead of leaving them inactive. If an update breaks the site, restore the backup or deactivate the offending plugin by renaming its folder under wp-content/plugins over FTP; WordPress then deactivates it automatically and the dashboard becomes reachable again. See Debugging WordPress for the white screen of death.

Maintenance mode

While an update or a redesign is in progress you can show visitors a friendly message instead of a half-broken site. WordPress does this itself during updates: it creates a file called .maintenance in the site root containing the time the update began.

PHP
<?php $upgrading = 1741600000; // read-only example

On every request WordPress reads that file, and as long as the timestamp is less than ten minutes old it answers with "Briefly unavailable for scheduled maintenance. Check back in a minute", sending HTTP status 503 Service Unavailable. After ten minutes it assumes something went wrong and ignores the file, which is also why a stuck .maintenance file after a failed update is the usual reason for a site stuck in maintenance (just delete the file over FTP).

PHP How WordPress decides if the site is in maintenance (stand-in)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with fgets(STDIN)), it gets the next line from this box.

For your own planned work use a plugin (WP Maintenance Mode, SeedProd, LightStart) or a builder's maintenance feature. A good maintenance page returns 503 with a Retry-After header, so search engines understand it is temporary and do not drop the pages, and it still lets logged-in administrators see the real site. Also use coming soon mode before launch, and remember to switch it off afterward.

The .htaccess file

On Apache (and LiteSpeed) servers, .htaccess is a per-directory configuration file that lives in the site root. WordPress uses it chiefly for pretty permalinks: it sends every request that is not a real file or folder to index.php, which then works out which post to show. Nginx has no .htaccess; the same rule sits in the server configuration (try_files $uri $uri/ /index.php?$args;).

When you select a permalink structure other than Plain, WordPress writes this block between markers:

APACHE
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

WordPress rewrites only the part between # BEGIN WordPress and # END WordPress, so you can keep your own rules above or below it. Common additions:

APACHE
# force HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

# protect wp-config.php
<Files wp-config.php>
    Require all denied
</Files>

# disable directory listings
Options -Indexes

# larger uploads (if the host allows php_value)
# php_value upload_max_filesize 64M

Creating the file: if it does not exist, saving Settings > Permalinks makes WordPress write it (when the folder is writable). Manually: in cPanel's File Manager enable Show hidden files in the settings, click + File, name it .htaccess (note the leading dot), paste the block above, set permissions to 644. Over SFTP, create a text file with that name on your computer and upload it. A broken .htaccess gives a 500 Internal Server Error, so keep a copy before editing; renaming it to .htaccess-old restores access so you can fix it. If your permalinks give 404 errors on every page except the home page, a missing or non-writable .htaccess is the most likely cause. See Rewrite Rules and Permalinks for the PHP side.

PHP Generating the WordPress rewrite block (stand-in)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with fgets(STDIN)), it gets the next line from this box.

The managed block is replaced for a site in the /blog/ subfolder, while Options -Indexes and the redirect stay untouched.

Clearing the cache

When a change does not appear, a cache is almost always serving the old copy. There can be several layers, so clear them from the inside out:

  1. Plugin page cache (WP Rocket, LiteSpeed Cache, W3 Total Cache, WP Super Cache): use Clear cache or Purge all in the admin bar or the plugin's screen. Also clear minified/combined CSS and JS files.
  2. Object cache (Redis, Memcached): flush it from the plugin or with wp cache flush.
  3. Server cache (host tools such as Varnish, Nginx FastCGI or LiteSpeed): use the host's panel button.
  4. CDN (Cloudflare and others): purge the CDN cache.
  5. Browser cache: hard reload (Ctrl+Shift+R) or a private window.

Clear caches after updates, theme changes and layout edits; for details on how page, object and transient caching work see Caching and WP-Cron and Performance Optimization.

Creating a Multisite network

A Multisite network runs many sites from one WordPress installation (see Multisite Overview for how it works). To enable it on an existing single site:

  1. Back up the site and deactivate all plugins.
  2. In wp-config.php, above the line "That's all, stop editing!", add:
PHP
define( 'WP_ALLOW_MULTISITE', true );
  1. Reload the dashboard and open Tools > Network Setup. Choose sub-directories (example.com/site2) or sub-domains (site2.example.com, which needs a wildcard DNS record). On an existing site that has been running for a while, only sub-domains may be offered.
  2. Fill in the network title and admin email and click Install.
  3. WordPress shows two blocks of code: constants for wp-config.php (MULTISITE, SUBDOMAIN_INSTALL, DOMAIN_CURRENT_SITE, and so on) and rules for .htaccess. Paste both in, replacing the old WordPress block in .htaccess.
  4. Log in again. A new My Sites > Network Admin menu appears, where you add sites, manage users, themes and plugins for the whole network.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Which two parts must a complete WordPress backup include?

    Content lives in the database, media and code in wp-content; wp-config.php is worth saving too.
  2. 2. Why should a backup also be stored off the server?

    A single location is a single point of failure. Follow the 3-2-1 rule.
  3. 3. A plugin update has caused the white screen and you cannot log in. What is a quick recovery?

    When WordPress cannot find an active plugin's folder it deactivates the plugin, so the dashboard loads again.
  4. 4. What does WordPress do with a .maintenance file that is older than ten minutes?

    The flag is only honoured for ten minutes; a stuck file is the usual cause of a site stuck in maintenance mode and can be removed manually.
  5. 5. What is the purpose of the WordPress block in .htaccess?

    The rewrite rules send every non-file, non-directory URL to index.php, where WordPress finds the right content.

Summary

  • Back up the database and the wp-content files automatically, keep several generations, store copies off the server and test a restore.
  • Use a backup plugin, phpMyAdmin or wp db export and file copies; restore the database, then the files, then check wp-config.php and permalinks.
  • Update core, plugins and themes regularly, after a backup and ideally on staging; recover from a bad update by renaming the plugin folder.
  • WordPress maintenance mode is a .maintenance file honoured for ten minutes and returns 503; use a plugin for planned downtime.
  • .htaccess holds the permalink rewrite block on Apache; a missing or broken file causes 404s or 500 errors.
  • Clear caches from the inside out: plugin, object, server, CDN, browser.
  • Enabling Multisite needs WP_ALLOW_MULTISITE, Network Setup, and new wp-config.php and .htaccess code.

Next: Sitemaps, SEO Basics and a Table of Contents.