WordPress Content Version Control and GitHub Backup - n8n Workflow

Secure your WordPress content using this advanced n8n workflow. Schedule automatic backups, compare content changes, and commit only new or modified posts to GitHub.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Blog administrators needing reliable, automatic content backups.

  • Developers interested in treating blog content as code for version history and retrieval.

  • n8n users seeking an advanced n8n template demonstrating complex differential logic and self-referencing workflows.

  • Anyone who needs a robust n8n workflow for GitHub file management.

Overview

This comprehensive n8n workflow is designed to ensure the integrity and version history of your WordPress content by backing up posts to a dedicated GitHub repository. Unlike simple backup solutions, this n8n automation only commits changes when content is genuinely new or modified, preventing unnecessary commits and maintaining a clean repository history. It utilizes a sophisticated sub-workflow structure and a custom n8n node for differential comparison of JSON content, making it an excellent example of advanced automation capabilities within n8n.

How it Works

The n8n workflow operates using a scheduled or manual start.


  1. Trigger and Extraction: The n8n trigger (either Schedule or Manual) initiates the process. The 'Get All WP Posts' n8n node retrieves all content from the configured WordPress site.

  2. Workflow Iteration: The 'Execute Workflow' n8n node then processes each WordPress post individually. Critically, this node executes the latter half of the same n8n workflow (acting as a sub-routine), passing the post data item-by-item.

  3. Setup and Retrieval: The sub-routine first defines global GitHub repository settings (Globals). It attempts to retrieve the existing backup file for that specific post from GitHub using the 'Get file data' n8n node. This node is configured to continue on failure, anticipating that the file might not exist (i.e., it's a new post).

  4. Content Comparison: The data flow merges the retrieved GitHub metadata with the actual WordPress content JSON. The custom 'isDiffOrNew' Code n8n node is executed. This specialized code handles decoding the base64 content from GitHub, orders the JSON keys of both the existing and new data to guarantee a reliable byte-for-byte comparison, and sets a status variable (github_status: "same", "different", or "new").

  5. Conditional Action: The 'Check Status' n8n node acts as a switch based on the comparison result.

If the status is "same", the n8n workflow skips the commit.
If the status is "different", the 'Edit existing file' GitHub n8n node updates the file with the new content.
* If the status is "new", the 'Create new file' GitHub n8n node creates the backup file for the first time.

This robust logic ensures that every n8n execution contributes meaningfully to your content versioning.

Installation Guide

To deploy this powerful n8n workflow template, follow these steps:


  1. Import: Copy the provided JSON data and import it directly into your n8n instance.

  2. WordPress Credentials: Configure the 'Get All WP Posts' n8n node with your WordPress API credentials.

  3. GitHub Credentials: Configure the GitHub n8n node credentials ('Get file data', 'Create new file', 'Edit existing file') using a Personal Access Token (PAT) with repository write permissions.

  4. Global Repository Settings: Locate the 'Globals' n8n node (position 200, 120). You must edit the parameters here:

Set repo.owner to your GitHub username or organization name.
Set repo.name to the name of your backup repository.
Optional:* Adjust repo.path if you want a specific directory structure for your backed-up files.

  1. Schedule: Review and adjust the 'Schedule Trigger' n8n node to match your desired backup frequency. The existing setting runs daily at 5 PM UTC.

Node Details

Schedule Trigger / Manual Trigger: Acts as the primary n8n trigger for starting the backup process, allowing either timed or instant execution.
WordPress n8n node (Get All WP Posts): Fetches all posts and pages from the WordPress site using the 'getAll' operation. This data forms the payload for the rest of the n8n workflow.
Execute Workflow n8n node: Essential for iterating through WordPress posts. It calls the same workflow ID in 'each' item mode, isolating the GitHub backup logic for every single post.
Set n8n node (Globals): Centralizes configuration for the GitHub repository owner, name, and the file path structure, improving maintenance for this n8n template.
GitHub n8n node (Get file data): Attempts to retrieve the existing JSON backup file for a specific WordPress item, using the item's ID in the filename. Crucially, it uses continueOnFail: true to handle cases where the file does not yet exist.
Code n8n node (isDiffOrNew): Contains the core version control logic. It handles Base64 decoding of the existing file and standardizes JSON object keys before performing a strict string comparison to determine if the content is 'same', 'different', or 'new'.
Switch n8n node (Check Status): Routes the flow based on the github_status determined by the previous n8n node, ensuring the correct GitHub action (skip, edit, or create) is taken.
GitHub n8n nodes (Create new file / Edit existing file): Performs the necessary file operations in the GitHub repository, committing the stringified WordPress content JSON with a relevant commit message indicating the status of the update.

Related n8n Workflows

Free

Nodes: 14 Nodes
Updated: December 26 2025
View all
Created by

Featured*