WordPress downgrade script

Whilst cleaning my local data, I found a script I had written to downgrade WordPress 6.2 installs to WordPress 6.1.1 specifically. While not current anymore, I thought it might be fun to share this as an example on how to script such a transaction:

#!/bin/bash
# Downgrade WP 6.2 to v6.1.1
#
# IMPORTANT: run this from the WP install root.

# Set base_path
base_path=$(pwd)

# Download and unzip 6.1.1 release files
function getWP611 {
    # move working directory to account root or subsites
    cd /tmp
    wget https://wordpress.org/wordpress-6.1.1.zip
    unzip wordpress-6.1.1.zip
    rm -rf wordpress-6.1.1.zip
}

function remove62 {
    cd $base_path
    rm -rf wp-admin
    rm -rf wp-includes
    rm -rf index.php wp-comments-post.php wp-cron.php wp-links-opml.php wp-login.php wp-settings.php wp-trackback.php wp-activate.php wp-blog-header.php wp-config-sample.php	wp-load.php wp-mail.php wp-signup.php xmlrpc.php
}

function move611 {
    cd /tmp/wordpress/
    cp -r wp-admin "$base_path"/wp-admin
    cp -r wp-includes "$base_path"/wp-includes
    cp wp-comments-post.php "$base_path"/wp-comments-post.php
    cp wp-cron.php "$base_path"/wp-cron.php
    cp wp-links-opml.php "$base_path"/wp-links-opml.php
    cp wp-login.php "$base_path"/wp-login.php
    cp wp-settings.php "$base_path"/wp-settings.php
    cp wp-trackback.php "$base_path"/wp-trackback.php
    cp wp-activate.php "$base_path"/wp-activate.php
    cp wp-blog-header.php "$base_path"/wp-blog-header.php
    cp wp-config-sample.php "$base_path"/wp-config-sample.php
    cp wp-load.php "$base_path"/wp-load.php
    cp wp-mail.php "$base_path"/wp-mail.php
    cp wp-signup.php "$base_path"/wp-signup.php
    cp xmlrpc.php "$base_path"/xmlrpc.php
    cp index.php "$base_path"/index.php
}

# Runner
getWP611
echo '6.1.1 downloaded and unzipped'
remove62
echo '6.2 core removed'
move611
echo '6.1.1 core files restored'

1 reactie

Jouwe toevoegen

  1. I always find something new and useful here. Fantastic job!

Geef een reactie

Je e-mailadres wordt niet gepubliceerd. Vereiste velden zijn gemarkeerd met *