ogo
Typetale
ogo
Typetale
  • Features
  • Pricing
  • Blog
  • What's new
  • FAQs
  • About
Start free trial
ogo
Typetale

The fastest way to launch your Ghost publication. Managed hosting with all the features you need to grow your audience.

Product

  • Features
  • Pricing
  • What's New
  • FAQ
  • Start Free Trial

Compare

  • vs WordPress
  • vs Substack
  • vs Medium
  • vs Ghost Pro

Alternative to

  • Ghost Pro
  • Substack
  • WordPress

Resources

  • About
  • Blog
  • Help Center

Legal

  • Privacy Policy
  • Terms of Service
  • SLA & Uptime
  • Refund Policy

Stay updated

Get the latest news, feature releases, and updates from Typetale delivered to your inbox. No spam, unsubscribe anytime.

© 2026 Typetale. All rights reserved.
GDPR-compliant • EU servers • Privacy-first analytics
Built with by the Typetale team

How to Back Up Ghost and Optimize MySQL Database Performance

By Tilak Sasmal — Tue Jun 16 2026

5 min read

How to Back Up Ghost and Optimize MySQL Database Performance

A single server crash can erase years of publishing history in a fraction of a second. Relying solely on the standard Ghost administrator dashboard export is a common mistake that leaves critical settings, subscriber open rates, and transactional data behind.

Securing your site requires a complete copy of both your database and your media content. This guide outlines how to configure reliable MySQL backups and optimize your database to keep your site loading instantly.

Why Database Maintenance Matters for Ghost Blog Optimization

Over time, database tables accumulate logs, temporary tokens, and session details that degrade page speed. Consistent database maintenance is a core requirement for successful Ghost blog optimization.

When database queries slow down, pages take longer to render. This delays your Time to First Byte (TTFB), frustrating visitors and harming search engine rankings.


Self-hosting: Guide to Logical Backups

A logical backup extracts database structure and content into a readable SQL file. You can run these commands directly on your server using SSH.

Finding Your Database Credentials

Before running backup tools, you must locate your credentials in the configuration settings.

  1. SSH into your server and navigate to your Ghost installation directory (typically /var/www/ghost).
  2. Open the config file using cat config.production.json.
  3. Locate the database block to copy your username, password, and database name.

Executing a Clean SQL Export

To prevent database locks during backup, use the single-transaction flag. This ensures your site remains online while the utility runs.

Run the following command:

mysqldump -u [db_user] -p --single-transaction --no-tablespaces [db_name] > backup.sql

Enter your password when prompted to complete the export.

Archiving contents directory

zip -r content.zip /var/www/ghost/content

Now, you can transfer content.zip and backup.sql to any cloud storage or local machine.


Automating the backup process

Manually executing commands daily is inefficient. Automating backups ensures you always have a clean recovery point — whether you need to perform a self-hosted Ghost migration, transfer Ghost blog to new host, or simply recover from a failed update.

Setting up a Cron Job

You can schedule automated tasks using the system cron daemon.

Just add below line to dump the database and zip the content directory at 2:00 AM daily. If you need to adjust the time, you use this free tool to get the right cron expression:

Open the cron editor and add the line:

crontab -e
0 2 * * * mysqldump -u [db_user] -p[db_pass] --single-transaction [db_name] > ~/backups/db.sql && zip -r ~/backups/content.zip /var/www/ghost/content

Doing the same on docker based deployment

If you run your ghost in containerized environments, your backup workflow changes slightly. You must extract the database from the container rather than the host system.

Run the database dump utility through Docker:

docker exec [container_name] /usr/bin/mysqldump -u root -p[root_password] [db_name] > docker-backup.sql

This is the recommended approach for a Ghost Docker migration, since the MySQL data lives inside the container's isolated filesystem rather than a directly accessible host path.

The same approach applies inside Docker. Schedule a daily dump from the running container with a cron entry:

0 2 * * * docker exec [container_name] /usr/bin/mysqldump -u root -p[root_password] [db_name] > ~/backups/docker-backup.sql && zip -r ~/backups/content.zip /[ghost container volume path]

Optimizing MySQL 8 Performance for Ghost CMS

Ghost relies on MySQL 8 for query processing. Configuring your database engine properly improves performance on low-resource virtual private servers.

Tuning the InnoDB Buffer Pool

The buffer pool caches table data and indexes. Allocating enough memory to this pool reduces disk input/output operations significantly.

Open your MySQL configuration file (/etc/mysql/my.cnf) and set the value to 50–70% of your total available RAM. On a server with 1 GB of RAM, 512M is a reasonable starting point:

[mysqld]
innodb_buffer_pool_size = 512M

Restart the MySQL service to apply the change. The table below summarises additional settings that collectively keep Ghost running efficiently.

Recommended System Settings

Optimization Setting Recommended Value Impact
innodb_buffer_pool_size 50% to 70% of system RAM Minimizes disk reads for cached queries
swap_space 2 GB minimum Prevents database crashes during traffic spikes
character_set_server utf8mb4 Supports full unicode, including emoji characters
collation_server utf8mb4_0900_ai_ci Ensures faster sorting and character comparison

Identifying Slow Queries with the MySQL Slow Query Log

Before blindly tweaking configuration values, identify which queries are actually slowing your site down. MySQL 8 ships with a built-in slow query log that records every query exceeding a set time threshold.

Enable it at runtime without restarting the server:

SET GLOBAL slow_query_log = 'ON';
SET GLOBAL long_query_time = 1.0;
SET GLOBAL slow_query_log_file = '/var/log/mysql/slow-query.log';

Once you have collected data, summarise the worst offenders:

mysqldumpslow -s t /var/log/mysql/slow-query.log

For a line-by-line breakdown of exactly how MySQL executes a specific query, prefix it with EXPLAIN ANALYZE. This tells you whether MySQL is using indexes or running a costly full table scan.

Reclaiming Disk Space by Purging Binary Logs

MySQL 8 enables binary logging by default. Left unchecked, these logs accumulate and can silently fill your server's disk — a common cause of unexpected database crashes on small VPS instances.

Set an automatic expiration window to keep disk usage in check:

SET PERSIST binlog_expire_logs_seconds = 604800; -- 7 days

If you need to reclaim space immediately, purge old logs manually:

PURGE BINARY LOGS BEFORE '2026-02-01 00:00:00';

Do not purge logs if you are running MySQL replication. Run SHOW REPLICA STATUS first and confirm there are no active replicas consuming those logs.

Tuning Ghost's Database Connection Pool

Ghost manages its own connection pool independently of MySQL's global max_connections setting. The default pool size handles small-to-medium publications comfortably, but high-traffic sites can exhaust connections and produce latency spikes.

Open config.production.json and adjust the pool limits under the database block:

"database": {
  "client": "mysql",
  "connection": { },
  "pool": {
    "min": 2,
    "max": 20
  }
}

Raise max only if you are seeing "Too many connections" errors in your Ghost logs. Every open connection consumes server memory, so increasing this value without increasing RAM can cause its own performance problems.

A Note on OPTIMIZE TABLE and MySQL Version

Running OPTIMIZE TABLE reorganises physical storage and reclaims space left behind by bulk deletions. For Ghost, which rarely performs mass deletes, this command is rarely necessary. Run it only after large import or purge operations, and always do so during a low-traffic window since it locks the table for the duration.

Finally, check which MySQL version you are running. MySQL 8.0 reached end-of-life in April 2026. If you are still on 8.0, plan an upgrade to MySQL 8.4 LTS for ongoing security patches and performance improvements.

What if you don't want to do all these yourself?

Self-hosting gives you full control, but the maintenance burden grows with your audience. Handling backups, updates, firewalls, and mail configurations manually consumes valuable writing time.

If your maintenance overhead is growing, evaluating the best managed Ghost hosting options is a logical next step — these platforms are built to handle the operational workload so you can stop managing servers and focus on writing.

Automated Redundant Backups

Enterprise-grade providers run scheduled snapshots across multiple geographical regions. This ensures that even if an entire data center goes offline, your publication can be restored instantly with no data loss.

If you are planning a Ghost to Typetale migration or moving from Ghost(Pro) to Typetale, these backup procedures are handled at the infrastructure level — no cron jobs or manual SQL dumps required. When running a Ghost hosting comparison, check how each provider handles geo-redundancy, backup frequency, and restoration speed. Those three factors matter far more than headline price when your publication is actively growing.

Read more

Ghost 6: Ghost CMS SQL Injection (v3.24.0 – v6.19.0)
Ghost 6: Ghost CMS SQL Injection (v3.24.0 – v6.19.0)

The cybersecurity community has identified a significant vulnerability within the Ghost CMS ecosystem. This is a third-party advisory intended to inform all administrators, developers, and stakeholder…

Tilak Sasmal•Feb 18, 2026•2 min read
Welcoming Ghost 6 native analytics
Welcoming Ghost 6 native analytics

We are going to deprecate the OG Plausible analytics in Favour of Ghost 6 introduced a native analytics. Read the post to know when we are going to sunset the OG Analytics.…

Tilak Sasmal•Sep 21, 2025•2 min read
Ghost 6 now on typetale!
Ghost 6 now on typetale!

Ghost 6 is now on Typetale! We've made some key changes to the official version to ensure your data stays private and your social network has no limits. Read on to learn how we're making Ghost 6 even …

Tilak Sasmal•Sep 18, 2025•2 min read
Feature drop from Typetale
Feature drop from Typetale

✨ Greetings, wonderful typetale community! Merry Christmas 🎅 As we wrap up this incredible year, I hope you're finding joy and good health in these festive moments! I'm excited to share my first fea…

Tilak Sasmal•Dec 25, 2024•1 min read