> ## Content Index
> Fetch the complete content index at: https://snubmonkey.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# GHOST CMS: backup and restore ⏤ Self-hosting.
- URL: https://snubmonkey.com/ghost-cms-how-to-restore-an-old-revision-of-a-ghost/
- Published: 2024-02-01T00:09:14.000Z
- Updated: 2025-07-17T19:09:09.000Z
- Description: We’ve talked a lot about security… but one of the most overlooked aspects of running a website is having a backup. You must take all necessary precautions to ensure that your website is regularly and safely backed up.
- Author: yannick Coffi
- Tags: how to 🪄, self-hosting 🪲, security 🦾🦿, linux 🐧

Maintaining a full backup of your website—including HTML, CSS, JavaScript, images, videos, and databases that store critical information such as user data and CMS configurations protects you from potential risks and ensures you can restore your site in the event of data loss, hacking, or other unexpected incidents.  

🎧 
  
  
[According to IBM's](https://www.ibm.com/reports/data-breach?ref=snubmonkey.com) *Cost of a Data Breach Report 2024*, the global average cost of a data breach reached **$4.88 million** in 2024—a [**10% jump**](https://www.vikingcloud.com/blog/the-real-cost-of-data-breach?ref=snubmonkey.com) from the previous year and the largest annual increase since the pandemic. That's a staggering figure, especially for small businesses. No matter your industry, customer base size, or how frequently you update your site, having a backup is the digital equivalent of keeping a spare tire in your trunk—you hope never to need it, but there's peace of mind knowing it's there. The same applies to your website.  
 BACKUPS ARE CRUCIAL \[period!\]

##   
**Backup Your Business**   
  
**Ghost doctor**

Before running into the backup we suggest that you run the following command `ghost doctor` first under your working directory.  
Running this will check the system for potential hiccups, and provide information about what needs to be resolved if any issues arise.  
  
See below (hiccups !!!)

```
$ ghost doctor
...
..
.

✔ Checking system Node.js version - found v18.19.0
✔ Checking logged in user
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
✔ Checking system compatibility
✔ Checking for a MySQL installation
+ sudo systemctl is-active ghost_localhost
Instance is currently running
ℹ Validating config [skipped]
✖ Checking folder permissions
✖ Checking file permissions
✖ Checking content folder ownership
✔ Checking memory availability
✔ Checking binary dependencies
✔ Checking free space
✔ Checking systemd unit file
✔ Checking systemd node version - found v18.19.0
One or more errors occurred.

1) Checking folder permissions

Message: Ghost can't access some files or directories to check for correct permissions.
Help: Run sudo find ./ -type d -exec chmod 00775 {} \; and try again.

2) Checking file permissions

Message: Ghost can't access some files or directories to check for correct permissions.
Help: Run sudo find ./ -type d -exec chmod 00775 {} \; and try again.

3) Checking content folder ownership

Message: Ghost can't access some files or directories to check for correct permissions.
Help: Run sudo find ./ -type d -exec chmod 00775 {} \; and try again.

Debug Information:
    OS: Ubuntu, v22.04.3 LTS
    Node Version: v18.19.0
    Ghost Version: 5.76.2
    Ghost-CLI Version: 1.25.3
    Environment: production
    Command: 'ghost doctor'

Try running ghost doctor to check your system for known issues.
```

  
As you can see from the report, Ghost can't access some files or directories because of some misconfigured permissions.  
In this case, we have to run the following command to get it fixed.

```
$ sudo find ./ -type d -exec chmod 00775 {} \;
```

  
Let's break it down a little.

`sudo` : we execute a command as **root** to level privileges.  
`find ./` : the `find` command is one of the most powerful tools in Linux, it searches for files in a directory hierarchy.  
`-type d` : find all directories in the current working directory.  
`-exec {} \;` : this tells `find` to execute a specified command on each file it locates. The `{}` acts as a placeholder that gets replaced with the current file name, and `\;` marks the end of the command. The command runs in the directory where `find` was originally executed. Only **one instance** of `{}` is allowed in the command. While many files may match the criteria, the actual number of command executions may be fewer, as find tries to group file names efficiently where possible.  
`chmod` : change file mode bits.  
  
  
Now, let's run the command one more time:  

```
$ ghost doctor
...
..
.

✔ Checking system Node.js version - found v18.19.0
✔ Checking logged in user
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
✔ Checking system compatibility
✔ Checking for a MySQL installation
+ sudo systemctl is-active ghost_localhost
Instance is currently running
ℹ Validating config [skipped]
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability
✔ Checking binary dependencies
✔ Checking free space
✔ Checking systemd unit file
✔ Checking systemd node version - found v18.19.0
```

All clear!  
  
Now, let's run the **backup** command:

```
$ ghost backup
...
..
.
= Checking for deprecations
...
..

+ sudo systemctl is-active ghost_localhost
+ sudo mkdir -p /var/www/snub_test/backup
? Enter your Ghost administrator email address youremail@whatever.com
? Enter your Ghost administrator password [hidden]
+ sudo cp /var/www/snub_test/backup/content-from-v5.76.2-on-2024-01-29-00-59-18.json /var/www/snub_test/content/data/content-from-v5.76.2-on-2024-01-29-00-59-18.json
+ sudo cp /var/www/snub_test/backup/members-from-v5.76.2-on-2024-01-29-00-59-18.csv /var/www/snub_test/content/data/members-from-v5.76.2-on-2024-01-29-00-59-18.csv
+ sudo chown -R ghost:ghost /var/www/snub_test/content
✔ Backing up site
Backup saved to /var/www/snub_test/backup-from-[backup-name].zip
```

###   
**Ghost backup**

The fastest way to back up your Ghost site is by using the Ghost CLI. With a single ghost backup command, it automatically generates a ZIP file containing all your site data. This step is especially important before upgrading to a major new version.  
The backup ZIP file includes:  

- Your content in JSON format
- A full member CSV export
- All installed themes, including your current active theme
- Images, files, and media (including video and audio)
- A copy of routes.yaml and redirects.yaml (or redirects.json)

###   

### **How to Remove Existing Content for a Clean Ghost Backup**

To avoid duplicating posts and to create a fresh backup, remove all existing content through the Ghost admin interface.  
  
Here's how you can delete content from your Ghost CMS:

1. Log in to your **Ghost admin dashboard**:  
 Access your Ghost site's admin dashboard by navigating to your site's URL followed by "/ghost" and logging in with your credentials.
2. **Settings**:  
 Go to settings (the **gear** or **cog wheel**)
3. **Navigate to Labs**:  
 On the Left end side, scroll down until you see **Labs**.
4. Labs menu  
On the right end side, under **Danger Zone**, click on **Delete all content**.  
\*This will permanently delete all posts and tags from the database, a hard reset.

### **Import your backup data**

With your new site up and running, it's time to bring your data over.  
  
Starting in your Ghost installation directory, extract the backup ZIP file directly into the **content** folder to restore your data:

```
$ sudo unzip /path/to/backup-from-v5.1xx.x-on-202x-0x-0x-2x-0x-1x.zip -d content
```

  
You should see something similar to the one below.

```
Archive:  /home/xxxx/backup-from-v5.1xx.x-on-202x-0x-0x-2x-0x-1x.zip
  inflating: content/data/content-from-v5.1xx.x-on-202x-0x-0x-2x-0x-1x.json
  inflating: content/data/members-from-v5.1xx.x-on-202x-0x-0x-2x-0x-1x.csv
   creating: content/files/2024/
   creating: content/files/2024/11/
  inflating: content/files/2024/11/49_most_used_linux_Commands_-you_should_know.pdf
  inflating: content/files/2024/11/top_five_-5-_most_commonly_used_commands.pdf
   creating: content/images/2023/
   creating: content/images/2023/08/
  inflating: content/images/2023/08/54673r.jpg
  inflating: content/images/2023/08/54673r_o.jpg
  inflating: content/images/2023/08/Gabriella_bennett.jpg
  inflating: content/images/2023/08/Gabriella_bennett_o.jpg
  inflating: content/images/2023/08/IMG_0399.jpg
  inflating: content/images/2023/08/IMG_0399_o.jpg
  inflating: content/images/2023/08/IMG_0645.jpg
  inflating: content/images/2023/08/IMG_0645_o.jpg
  inflating: content/images/2023/08/IMG_9525.jpg
  inflating: content/images/2023/08/IMG_9525_o.jpg
  inflating: content/images/2023/08/alias.jpg
  inflating: content/images/2023/08/alias_o.jpg
  inflating: content/images/2023/08/between_apt.jpg
  inflating: content/images/2023/08/between_apt_o.jpg
  ...
  ..
  .
```
  
  
**`zip`** is a command-line utility used to **compress files and directories**, making them easier to transfer, store, or email.  
In contrast, **`unzip`** is used to **decompress** those files, restoring them to their original form.  
  
If not installed, you might see something like this:

```
$ sudo unzip: command not found.
```

proceed with

```
$ sudo apt install unzip
```

or 

```
$ brew install unzip
```

for macOS users.

### **Next**;

1. Make sure the files have the right permissions:

```
$ sudo chown -R ghost:ghost content
```

1. Restart Ghost:

```
$ ghost restart -d /path/to/where/is/ghost_installed
```

1. Import your content:

```
$ ghost import content/data/content-from-v5.1xx.x-on-202x-0x-0x-2x-0x-1x.json
```

This requires your **username** and **password**, and can also be done on the labs page in Ghost Admin.
  
  
Backing up your website might seem boring, but it's an absolute lifesaver when things go wrong. I can't stress enough how critical backups are—they're not just a good habit, they're a vital part of your overall security strategy.  
  
We hope you found these tips helpful and interesting!