Skip to content

Shell scripts for cloning a WordPress site to a new domain and interacting with a WP db by using credentials in a wp-config.php file

License

Notifications You must be signed in to change notification settings

rausanka/WordPressHelpers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 

Repository files navigation

WordPressHelpers

A handy collection of shell scripts for working with WordPress installs (initially built for MediaTemple sites).

Main Script

sitecopy.sh - Copies a wordpress site from one domain to another. Uses wpdbclear.sh, wpdbdump.sh, and Search Replace DB.

Usage:

sitecopy.sh [options] old_domain new_domain

Options:
   -h                   Show this message
   --artifactdir=PATH   Place to put backups and migration artifacts. Defaults to working directory.
   --oldsitedir=PATH    Server address. Defaults to '~/domains/OLD_DOMAIN/html'
   --newsitedir=PATH    Server root password. Defaults to '~/domains/NEW_DOMAIN/html'

What sitecopy.sh does:

  1. Creates a directory for artifacts (uses the current timestamp - YYYYmmddHHMMSS)
  2. Backs up up the site to overwrite into the artifacts directory (new_domain)
  3. tars the web root directory
  4. Dumps the database using wpdbdump.sh
  5. Adds the database dump to the site tar file
  6. gzips the tar file
  7. Deletes the database dump
  8. Backs up the domain to copy (old_domain)
  9. Prepares copy of old_domain's database for new_domain
  10. Dumps old_domain's database using wpdbdump.sh
  11. Creates a copy of the old_domain db backup to be modified for new_domain
  12. Switches table prefixes in copy to match new_domain's wp-config.php prefix
  13. Preserves new_domain's wp-config.php file for swapping into old_domain's source directory
  14. Replaces new_domain's source code with old_domain's
  15. Nukes new_domain's source code
  16. Extracts old_domain's tar into new_domain's place
  17. Nukes any updraft backups or logs in new_domain
  18. Replaces all mentions of old_domain in new_domain's source code with new_domain
  19. Overwrites new_domain wp-config.php file with preserved version
  20. Runs wpclear.sh to replace new_domain's database with old_domain copy
  21. Drops new_domain's database and re-creates it
  22. Imports copy of old_domain's database
  23. Runs Search Replace DB to replace all instances of old_domain with new_domain

Helper Scripts

  • wpdbclear.sh - Replaces a database with a dump file using the credentials in a wp-config.php file.
  • wpdbdump.sh - Dumps a wordpress database using the credentials in a wp-config.php file.
  • wpdbgetcred.sh - Gets a specified database credential from a wp-config.php file.
  • wpdblogin.sh - Logs into a mysql prompt using the database credentials in a speficied wp-config.php file.

About

Shell scripts for cloning a WordPress site to a new domain and interacting with a WP db by using credentials in a wp-config.php file

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published