Moving a WordPress instance by hand

Over the years I’ve migrated a lot of WordPress sites. Although there are plugins that can take care of it, I have yet to find a more efficient way than just doing it by hand. The following is my recipe for migrating WordPress instances.

In the example we move a site to our local development environment.


  • Shell (usually SSH) access to the server that runs the WordPress instance
  • PHP CLI (sudo apt install php-cli)
  • WP-CLI

Obtaining code and DB from the source server

  1. Make a tarball of the site’s files:
    tar czf example.com.tgz public_html
    If it’s only for testing and you’re in a hurry, exclude the WP Uploads directory:
    tar czf example.com.tgz --exclude=**/wp-content/uploads/* public_html
  2. Find database credentials:
    grep DB_ public_html/wp-config.php
  3. Using the found credentials, make a database dump:
    mysqldump somedb -u someuser -p'somepassword' | gzip > example.com.sql.gz

Now copy the tarball and ‘sql-ball’ over to your machine.

Setting up local environment

  1. Unpack the WordPress instance:
    tar xzf example.com.tgz
  2. Create and import the database, e.g.:
    sudo mysqladmin create example_com
    zcat example.com.sql.gz | sudo mysql example_com
  3. Update database credentials in wp-config.php
    For local development, I usually just take user ‘root’ with an empty password (the Gods of Security frown upon me)
  4. To not need HTTPS locally:
    a. Remove any line containing “FORCE_SSL_ADMIN” from wp-config.php
    b. Remove or rename (= deactivate) any plugin (from wp-content/plugins) that forces ssl, for instance ‘really-simple-ssl’
  5. Replace your WordPress base URL using wp-cli:
    wp search-replace https://example.com http://localhost:8080
  6. Run the local development server:
    PHP_CLI_SERVER_WORKERS=50 wp server --port=8080

You should now be able to access the WordPress site by visiting http://localhost:8080 !

Optional, but handy

Create an admin user for yourself:
wp user create myadmin [email protected] --role=administrator --user_pass=admin


If connecting to the database fails, it could be that an empty password is not accepted. As using root with an empty password is a bit of a hack, here’s another hack to make it work for newer versions of MySQL/MariaDB. Obtain a root MySQL shell and execute:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '';


HOWTO: rtorrent + rutorrent on the Netgear ReadyNAS 102

In 14 short steps. Wonderful!


  • A Netgear ReadyNAS 102 with firmware version 6.1.6 to 6.1.8, which I’ve tested this on
  • Root access to the NAS. All the commands in this tutorial should be run as root

NOTE: This tutorial probably works for any system running Debian Wheezy.

Read the rest of this entry »

Tags: , , ,
| Posted in Tutorials | 1 Comment »

HOWTO: Unattended rdiff-backup + multiple commands

Here’s a small addition to Dean Gaudet’s tutorial on how to set up rdiff-backup for secure, unattended remote backups.

The scenario: you want host1 to pull backups from:

host2 : /var/log
host2 : /var/www

You’ve set everything up:

  • A non-root user on host1 called backupuser which initiates the backup
  • SSH private/public keys for┬ábackupuser
  • Added backupuser’s public key to host2:/root/.ssh/authorized_keys
  • An entry for host2 preconfigured in host1:~/.ssh/config as explained in the original tutorial.

Then you find out that in authorized_keys, you can only limit backupuser to run one command, not multiple:

[email protected]:~# cat /root/.ssh/authorized_keys
command="commandname" ssh-rsa FBwfijwefwB(...etc...)

Read the rest of this entry »

Tags: , ,
| Posted in Tutorials | No Comments »