# Copying a Wordpress site



## balanga (May 31, 2019)

I'd like to keep a copy of a Wordpress site on another system on my LAN and wondered what the best way of doing this was...

I think the alternatives are to copy the mysql files from one system to the other, or maybe use the two mysql severs to interact in some way. Also I'm not sure if Wordpress itself would hold any configuration files, or is all data stored in sql tables


----------



## Lamia (May 31, 2019)

Config file is wpconfig.conf. Texts used to be stored in db and images in dirs. Perhaps, I prefer to store media in a folder and create links to them in the posts.

You will need sync your db and folders to create a backup. There might now be an extension/plug-in that can do the syncing.


----------



## usdmatt (May 31, 2019)

You can generally get away with copying the entire website directory, and just doing a backup/restore of the database.

Configuration is in wp-config.php in the root website directory if you need to change database details. There isn't really much else to change in there, pretty much everything is in the database.

Note that Wordpress wants full write access to everything. (Either the entire website owned by the web user, or via one of the methods that allows PHP to run as the website owner's user). I'm not particularly keen on this but you'll get various things complaining in the admin otherwise, version upgrades being the obvious one.

It becomes more of a pain if you want to change the URL as you'll find it's stored all over the place. In this case change the URL in the main site settings, then get a well reviewed find/replace plugin to change any references hidden away in content stored in the database.


----------



## obsigna (May 31, 2019)

There may be the obstacle that the articles may contain a lot of absolute instead of relative links to media and other articles of the site. When I used WordPress for my BLog, perhaps I did something wrong, however my articles contained tons of absolute links which needed to be converted when I transferred the database to a clone in my local network. Without conversion, all that links would have pointed still to the production site blog.obsigna.net instead of local.obsigna.net. Nowadays, my BLog is based on a different system on obsigna.com.

In case you need to care for absolute link conversion when transferring WordPress databases to another site, you may want to adapt the shell script which I still provide on my BLog: Transfer of the MySQL data of a WordPress Site to a different domain


----------



## Lamia (May 31, 2019)

obsigna said:


> There may be the obstacle that the articles may contain a lot of absolute instead of relative links to media and other articles of the site. When I used WordPress for my BLog, perhaps I did something wrong, however my articles contained tons of absolute links which needed to be converted when I transferred the database to a clone in my local network. Without conversion, all that links would have pointed still to the production site blog.obsigna.net instead of local.obsigna.net. Nowadays, my BLog is based on a different system on obsigna.com.
> 
> In case you need to care for absolute link conversion when transferring WordPress databases to another site, you may want to adapt the shell script which I still provide on my BLog: Transfer of the MySQL data of a WordPress Site to a different domain


I can't agree more.

Has balanga taken a look at other authoring tools e.g. ContentTools/ContentCGI (https://obsigna.com/articles/1529528376.html). A flat file db should be a rational db/backend for a simple enterprise blog.

There are a few other great pkgs - CMS - with flat file, nosql or sqlite db out there.


----------



## usdmatt (May 31, 2019)

> There may be the obstacle that the articles may contain a lot of absolute instead of relative links to media and other articles of the site. When I used WordPress for my Blog, perhaps I did something wrong, however my articles contained tons of absolute links which needed to be converted when I transferred the database to a clone in my local network.



I'm not a big Wordpress expert but I always find the same thing. 



> In case you need to care for absolute link conversion when transferring WordPress databases to another site, you may want to adapt the shell script which I still provide on my BLog



If that worked for you then great, but I wouldn't advise it. Various features in Wordpress store data as serialised PHP; You'll see it all over the place in the database. Serialised PHP stores the length of strings, so if you modify a string manually, PHP will reject it when you try and deserialise it. I mentioned using a plugin above; I just looked up the one I use - "Better Search Replace", which lets you do a dry run and transparently handled serialised data.



> Has balanga taken a look at other authoring tools



He doesn't suggest that he had involvement with developing the site so may not have had a choice on CMS system. I really don't like a lot of things about Wordpress, but it's pretty much become an industry standard now unfortunately. Something ridiculous like 25% of websites use it (obviously that's skewed by the vast number of crappy blogs or 2 minute business websites, whereas very few of the top websites will be using it).

It's becoming a bit like the old "you can't go far wrong buying IBM or Cisco" saying. You're never going to have trouble finding a host that supports Wordpress. You'll never have trouble finding a developer to work on it. And regardless of what you want the website to do, there's probably a plugin for it that would take months of development if you have to implement it yourself.


----------



## obsigna (May 31, 2019)

usdmatt, thanks for the pointer. I looked into the final backup SQL dump of my old BLog, and as a matter of fact, the links which are part of some WP admin panel settings are stored in the following form: 
	
	



```
s:50:\"https://the.absolute.link/to/the/very/resource.xyz\";
```
However, all links in the articles and comments are plain strings embedded as the attribute in respective HTML tags, e.g. <a href> or <img src>, etc. Therefore, using the script, the articles would be correctly re-linked, while settings in the various WP admin panels would probably be not, except for the rare case where the new domain got the same string length as the old one.


----------



## marcuscole (Apr 30, 2022)

The best and the easiest way to go is to create a git repo of the current live site and then create a clone on your local environment. This won't transfer over the database so you will have to relocate the DB over yourself which is a simple thing to do. If you don't want to mess with git find a site migration plugin and use that. My personal favorite is backup-buddy but that requires paying for it and you will have to move over files that you change to the live site. Transform Agency did that for me first but I've learned the process from them.


----------

