WP Scripts

WP Scripts is a set of simple vbScript files that can help you maintain your WordPress database and custom WordPress files.  WP Scripts includes a backup script that can be used to schedule a regular backup of your blog database. It also includes upload and download scripts that you can use to synchronize a test and production copy of your blog. The upload feature also makes it easier to install plugins and new themes.  The scripts were designed to run on Windows XP desktop machines.  They have only been tested on PCs running Windows XP.

Definitions

Production – This word is used when referring to systems that are live and accessible to users.  This is the live blog that your readers see.

Test – This is a copy of your live blog.  It can be used to test new plugins, themes, and upgrades.  Only make changes to your files in the test copy.  Then migrate those changes to production.  If you follow a migration process, you’ll catch errors in your blog before they affect your readers.

 
Creating A Test Blog

Copy all of the files from your live blog into a different directory.  For example, if your blog is in a /blog directory, you can copy the files into a /blog_test directory.

Assuming you’re restricted to a single database, you’ll need to change your table prefix and copy your database files.

In the test directory, open your wp-config.php file and change the table prefix.  You don’t want your test blog and production blog pointing to the same database tables:

Change this:

$table_prefix  = ‘wp_’;  

To something like this:

$table_prefix  = ‘wpt_’;  

 

Then, open your database tool (probably PHPMyAdmin).  You need to copy each table that has a prefix matching your production blog.  Copy each table and change the name to match the prefix of your test blog.

copy For example, you would copy wp_users to wpt_users.

There are many ways to do this, but it doesn’t take long to copy the typical ’10′ WordPress tables.  Note, some plugins create their own tables and they might not have table prefixes.  If possible, it’s best to have a separate test database.  If not, try to identify the plugins and disable them in your test database.

 

WP Scripts Installation

Download the WP Scripts ZIP file.

Extract the files. I suggest extracting the files directly to the root of your ‘c:’ drive. This will ensure that you won’t have any directories with spaces in the names. Spaces in directory names can sometimes cause trouble with command-line utilities.

 

Backup

Open db-backup.vbs and edit the following lines.


host = "[db host]" 'IP Address of your MySQL Server
db_name = "[db name]" 'The name of the database
user = "[username]" 'Your MySQL username
pass = "[password]" 'Your MySQL password

Example:


host = "10.52.3.100" 'IP Address of your MySQL Server
db_name = "wordpress" 'The name of the database
user = "swhitley" 'Your MySQL username
pass = "mag1cb3ans" 'Your MySQL password

You can run the backup by double-clicking on the db-backup.vbs file. It will create a directory called db-backup and dump your database into that directory. If you schedule this script to run using Windows Scheduler, a separate copy of your database will be stored in the folder. This can be helpful if you find an error in your database and you realize that the last good copy was backed up last week.

To use Windows Scheduler, navigate to Start, Programs, Accessories, System Tools. Setup a regular schedule for your backups and you’ll be prepared if something goes wrong with your blog.

Synchronize (Upload/Download)

Setup the synchronization scripts by opening the config.txt file.

Overwrite the sample entry with your blog ftp site information:


My Blog
ftp.myblog.com
argus
a1st3ak
myblog
./myblog
end

Example


Hover Press
ftp.hoverpress.com
tripod
tr1pd123
hoverpress_blog
./hvr
end

You can copy these lines and paste them below your first set to define additional blogs. In this way, you can create an entry for your test blog and your production blog. You can point both entries to the same local directory. You can then download from your test blog to the local directory and then upload from the same directory to your production blog. Using the upload/download process, you can migrate code from test to production smoothly.

Upload/Download with New Plugins and Themes

These are the steps you’d use to test a plugin before moving it into production.

  • Your config.txt file should already be setup for both your test and production blog.
  • Double-click the download.vbs file.
  • Select the test blog by entering its number into the dialog box and press OK.
  • The plugin and themes from your test blog will be downloaded to your hard drive. This is your local copy.
  • Download a new plugin and extract the files to the local copy of your blog. Place the plugin files in the plugin folder.
  • Double-click the upload.vbs file
  • Again, select the test blog by entering its number in the dialog box and pressing enter.
  • The plugin will be uploaded to your test blog.
  • Activate the plugin on your test blog and make sure that everything still works.
  • If everything looks good, double-click the upload.vbs file again.
  • This time, select your production blog.
  • The plugin will be migrated to your production blog and you can complete the process by activating the plugin in production.

 

Back to the Basics

It’s tough sometimes to stop and think about your blog as more than a simple piece of software.  However, there are many components in a WordPress system that can go wrong.  The best way to prevent a lot of frustration for you and your readers is to backup, test, and only migrate code.  These are practices that have been followed for many years by professional system administrators, and like it or not, you’re in that role when you’re running your own blog.

Share

Leave a Reply

Twitter Tweet This