Giter Club home page Giter Club logo

wordpress-tools's Introduction

WordPress Tools

This repository contains various free scripts for WordPress site management and migration.

WordPress Site Transfer

The site-transfer.sh script is designed to automate the process of migrating a WordPress site from one server to another. It performs a series of actions to ensure a smooth transfer:

  • On the source server, it identifies the WordPress installation directory, exports the database to a SQL file, compresses the database and WordPress files into a single archive, and prepares it for transfer.
  • On the destination server, it retrieves the compressed archive, decompresses it, imports the database content to a new database, and adjusts the WordPress configuration to match the new environment.

Prerequisites

  • SSH access to both source and destination servers
  • wget installed on both servers

Usage

On the Source Server

  1. Navigate to the root directory of your current WordPress site (where wp-config.php is located).

  2. Download site-transfer.sh using the following command and make it executable:

    wget https://raw.githubusercontent.com/connectplatform/wordpress-tools/main/site-transfer.sh && chmod +x site-transfer.sh
  3. Run the script and choose option 1 to create a backup:

    ./site-transfer.sh

On the Destination Server

  1. Navigate to the public directory where you plan to move your WordPress site (next to your future wp-config.php).

  2. Download site-transfer.sh as described above.

  3. Run the script and choose option 2 to restore the site:

    ./site-transfer.sh

MySQL Database Optimization

The optimize-db.sh script is designed to automatically optimize all tables in a WordPress database. Regular optimization of the database can help improve performance by defragmenting the database storage. This is particularly beneficial for sites with frequent updates or deletions.

Prerequisites

  • SSH access to the server where the WordPress site is hosted.
  • MySQL user credentials with the necessary privileges to perform optimizations (typically the same credentials used by WordPress in wp-config.php).

Usage

  1. Download the Script: Download db-optimizer.sh to the root directory of your WordPress installation (where wp-config.php is located).

    wget https://raw.githubusercontent.com/connectplatform/wordpress-tools/main/db-optimizer.sh && chmod +x db-optimizer.sh
  2. Run the Script:

    ./db-optimizer.sh

Scheduling with Cron

To automate the database optimization process, you can schedule the db-optimizer.sh script to run at a specific time using cron. For example, to run the script at 5 AM every three days, you would add the following cron job:

  1. Open your crontab for editing:

    crontab -e
  2. Add the following line to the crontab file (use 'crontab -e' to edit crontab):

    0 5 */3 * * /path/to/wordpress/db-optimizer.sh

    Replace /path/to/wordpress/ with the actual path to your WordPress installation directory.

  3. Save and close the crontab file. The cron daemon will automatically pick up this new job and run the script at the specified time.

Important Notes

  • Performance Impact: Be aware that running this script can temporarily impact the performance of your WordPress site, as the OPTIMIZE TABLE command locks tables during optimization. It's recommended to run this script during low-traffic periods, for example, at 5AM.

MyISAM to InnoDB Conversion

The myisam2innodb.sh script is designed to transition all MyISAM tables in a given WordPress database to the InnoDB storage engine. The InnoDB engine provides better performance and reliability for WordPress sites, particularly those utilizing WooCommerce, by supporting advanced features such as transactional data integrity and row-level locking.

Prerequisites

  • SSH access to the server where the WordPress site is hosted.
  • MySQL or MariaDB root or equivalent user credentials.
  • The wp-config.php file must be present in the directory from which the script is executed, as it is used to extract the database name.

Overview

This script performs the following operations:

  1. Extracts the Database Name: Reads the wp-config.php file to find the WordPress database name.
  2. Database Backup: Creates a full backup of the WordPress database, naming the file after the database with a -backup.sql suffix. This step is crucial for data safety, allowing recovery in case of any issues during the conversion process.
  3. Converts Tables: Converts all tables from MyISAM to InnoDB, ensuring that the database is fully compatible with the InnoDB engine for improved performance and stability.

Usage

  1. Prepare the Script:

    • Download myisam2innodb.sh into the root directory of your WordPress site (where wp-config.php is located).

    • Make the script executable:

       wget https://github.com/connectplatform/wordpress-tools/raw/main/myisam2innodb.sh && chmod +x myisam2innodb.sh
  2. Execute the Script:

    • Run the script by typing:

      ./myisam2innodb.sh
    • When prompted, enter the MySQL/MariaDB root password.

Important Notes

  • Data Safety: The script starts by creating a backup of your database. Ensure you have enough disk space for this backup.
  • Downtime Consideration: While the conversion process is generally quick, large databases might experience a brief downtime. Plan to run this script during low-traffic periods.
  • Performance Monitoring: After conversion, monitor your site's performance. Consider adjusting your MySQL/MariaDB configuration to optimize InnoDB performance, such as tuning innodb_buffer_pool_size.

Contributing

Contributions to enhance the functionality of these scripts are welcome. Please feel free to fork the repository, make your changes, and submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Authors

Ray Sorkin LinkedIn Twitter Telegram

wordpress-tools's People

Contributors

connectplatform avatar

Stargazers

Jay Thomason avatar  avatar

Watchers

 avatar

Forkers

brianjohnpenner

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.