By Tilak Sasmal — Tue Jun 16 2026
5 min read

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.
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.
A logical backup extracts database structure and content into a readable SQL file. You can run these commands directly on your server using SSH.
Before running backup tools, you must locate your credentials in the configuration settings.
/var/www/ghost).cat config.production.json.database block to copy your username, password, and database name.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.
zip -r content.zip /var/www/ghost/content
Now, you can transfer content.zip and backup.sql to any cloud storage or local machine.
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.
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
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]
Ghost relies on MySQL 8 for query processing. Configuring your database engine properly improves performance on low-resource virtual private servers.
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.
| 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 |
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.
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.
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.
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.
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.
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.