Oct 28

Recently I had to create a clone of this blog site so we can apply upgrades and test these out without fear of breaking our actual blogs. Here’s a list of steps I followed. Hopefully, it’ll help others.

Assumptions:

  •    existing blog URL: http://a.com.
  •    New blog URL: http://b.com/wordpress
  •    Existing blog is installed in /var/www
  •    New blog will be installed in /var/www/wordpress
  •    The MySQL database for wordpress content is called ‘wordpress’. Username and passwords are also ‘wordpress’
ssh root@a.com
 cd /var/
 tar cf wordpress.tar www
 bzip2 wordpress.tar
 mysqldump --add-drop-table-uwordpress -pwordpress -Dwordpress -hlocalhost > db.backup
 bzip2 db.backup
 scp wordpress.tar.bz2 db.backup.bz2 root@b.com:/var/www
ssh root@b.com
 cd /var
 tar jxf wordpress.tar.bz2
 mysql -uroot -p<mysql root="" pw="">         
 create database wordpress;
 GRANT ALL PRIVILEGES ON wordpress.* to 'wordpress'@'localhost' identified by 'wordpress*'; 
 exit;  
 cd /var/www  bunzip2 db.backup.bz2 
 mysql -uwordpress -p'wordpress' -Dwordpress -hlocalhost < db.backup  
 cd /var/www
 mkdir wordpress 
 cd wordpress 
 mv ../wordpress.tar.bz2 .   
 tar jxf wordpress.tar.bz2  
 mv www/* .  
 rm -rfwordpress.tar.bz2 www     
 cd /var/www    
 mysql-uwordpress -p'wordpress' -Dwordpress -hlocalhost
    update wp_posts set guid=REPLACE(guid,'http://a.com','http://b.com/wordpress');         
    update wp_options set option_value='http://b.com/wordpress/' where option_name='siteurl';   
    exit;

You should be able to login as admin at http://b.com/wordpress/wp-admin

Goto Settings/General and change all instances of http://a.com to http://b.com/wordpress

You might also have to goto your currently selected theme and make sure URLs are changed. Some themes have URLs embedded in them.

 

Tagged with:
preload preload preload