Our Migration Philosophy: Git for Code, Script for Data
At CODE TOT, we have a proven approach to managing our WordPress installations that ensures both efficiency and security. Our philosophy revolves around using Git for all theme and plugin code, while script-driven solutions handle the transfer of data. This method is designed to streamline the migration process without compromising the integrity or functionality of your site.
Why Git for Code?
- Faster Deployment: With all code under version control, pushing updates and changes between environments becomes instantaneous.
- Better Collaboration: Multiple developers can work on the same codebase without conflicts.
- Easier Rollbacks: If something goes wrong, you can easily revert to a previous commit or branch.
Why Script for Data?
- Incremental Updates: Only the necessary data (database and uploads) is transferred, conserving bandwidth and speeding up the process.
- Minimal Downtime: The script minimizes downtime by not deploying code directly onto the target server.
- Reduced Manual Errors: Automating repetitive tasks reduces human error and saves time.
Prerequisites
To use this migration script, you will need:
- A running WordPress site with a Git repository for themes and plugins.
- SSH access credentials to both the source and destination servers.
- The
rsync,ssh, andwgetcommands available on your server. - Installed version of WP-CLI.
Usage and Examples
The script can be executed with the following usage details:
./wp-migration.sh user@host:port sampleapp [destapp]
Example for same app migration:
./wp-migration.sh runcloud@sample.server.com:22 sampleapp
Example for different app migration:
./wp-migration.sh runcloud@sample.server.com:22 sampleapp destapp
What the Script Transfers
- The WordPress database using
wp db export. - WordPress configuration file (
wp-config.php). - .htaccess and .htninja files (NinjaFirewall config) if they exist.
- The uploads directory (typically located at
/wp-content/uploads/). - A copy of the database export SQL file on the local machine.
Post-Migration Steps (Manual)
After running the migration script, you will need to manually complete a few steps to ensure your site functions correctly:
- Import Database on Destination: Transfer the SQL file to the destination server and import it into the database.
- Run WP-Search and Replace: Execute the WP-Search and Replace utility to update all URLs in your database to reflect the new domain. You can use a tool like InterConnect IT’s Search and Replace Tool.
- Fix File Permissions: Ensure that file permissions are correctly set on the destination server to prevent any issues with WordPress functionality. Typical WordPress directories should have permissions set to 755, while files should have permissions set to 644.
- Flush Cache: Clear any caching mechanisms you might be using (e.g., W3 Total Cache or WP Super Cache) to ensure that the most recent changes are reflected on your live site.
Important Notes
- This script is intended for use with RunCloud servers, so some commands and paths may vary depending on your server setup.
- Always test your migration in a development or staging environment before deploying to production to identify any potential issues.
- If you encounter any issues during the migration, consult the logs or seek assistance from your hosting provider or community forums.
Download URL: https://raw.githubusercontent.com/codetot-web/runcloud-bash-scripts/refs/heads/main/wp-migration.sh
Repository: https://github.com/codetot-web/runcloud-bash-scripts


