This repository contains various free scripts for WordPress site management and migration.
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.
- SSH access to both source and destination servers
wget
installed on both servers
-
Navigate to the root directory of your current WordPress site (where
wp-config.php
is located). -
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
-
Run the script and choose option 1 to create a backup:
./site-transfer.sh
-
Navigate to the public directory where you plan to move your WordPress site (next to your future wp-config.php).
-
Download
site-transfer.sh
as described above. -
Run the script and choose option 2 to restore the site:
./site-transfer.sh
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.
- 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
).
-
Download the Script: Download
db-optimizer.sh
to the root directory of your WordPress installation (wherewp-config.php
is located).wget https://raw.githubusercontent.com/connectplatform/wordpress-tools/main/db-optimizer.sh && chmod +x db-optimizer.sh
-
Run the Script:
./db-optimizer.sh
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:
-
Open your crontab for editing:
crontab -e
-
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.
-
Save and close the crontab file. The cron daemon will automatically pick up this new job and run the script at the specified time.
- 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.
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.
- 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.
This script performs the following operations:
- Extracts the Database Name: Reads the
wp-config.php
file to find the WordPress database name. - 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. - 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.
-
Prepare the Script:
-
Download
myisam2innodb.sh
into the root directory of your WordPress site (wherewp-config.php
is located). -
Make the script executable:
wget https://github.com/connectplatform/wordpress-tools/raw/main/myisam2innodb.sh && chmod +x myisam2innodb.sh
-
-
Execute the Script:
-
Run the script by typing:
./myisam2innodb.sh
-
When prompted, enter the MySQL/MariaDB root password.
-
- 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
.
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.
This project is licensed under the MIT License - see the LICENSE file for details.