{"id":41,"date":"2026-03-01T20:10:01","date_gmt":"2026-03-01T20:10:01","guid":{"rendered":"https:\/\/www.test2.laoku.co.uk\/?p=41"},"modified":"2026-03-18T09:34:30","modified_gmt":"2026-03-18T09:34:30","slug":"website-porting","status":"publish","type":"post","link":"https:\/\/www.test2.laoku.co.uk\/index.php\/2026\/03\/01\/website-porting\/","title":{"rendered":"Website porting"},"content":{"rendered":"\n<div class=\"wp-block-group has-base-background-color has-background has-global-padding is-layout-constrained wp-container-core-group-is-layout-36304d0f wp-block-group-is-layout-constrained\" style=\"margin-top:var(--wp--preset--spacing--30);margin-bottom:var(--wp--preset--spacing--30);padding-right:0;padding-left:0\">\n<p>So, its been a struggle but got it sorted now. I can port from one address to another. Within the docker containers under my charge anyway. Some pointers I found useful<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use a separate container for each DB unless you <em>want<\/em> to increase complexity. Although now I have the process sorted out, it should be fine even with multiple databases in the mysql instance<\/li>\n\n\n\n<li>Get your wordpress \/ database environment up and running before &#8220;overwriting&#8221; it. Allows you to check everything is working first.<\/li>\n\n\n\n<li>Keep the default wordpress table prefix&#8217;s. Otherwise it will require further search\/replace actions.<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<p>So. My starting point.<\/p>\n\n\n\n<p>I created a new wordpress instance within my docker compose setup. Set it up under Caddy so it gets https. My website is technically two containers. One is WordPress:apache. The other is MySQL. These work in cooperation along with Caddy (Reverse proxy).<\/p>\n\n\n\n<p>I have one additional container I am using for maintenance at the moment. I am running an instance of Myphpadmin for visual inspection of databases. <\/p>\n\n\n\n<p>Step 1. Copying all the website data. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#Login to the remote server\nssh name@server\n\n#Check the name of the running #containers\ndocker ps\n\n#login to the relevant container\ndocker exec -it wp-server bash\n<\/code><\/pre>\n\n\n\n<p>You are now logged into the wordpress server in a bash terminal. By default, it pops you into <\/p>\n\n\n\n<p style=\"margin-top:var(--wp--preset--spacing--20);margin-bottom:var(--wp--preset--spacing--20)\">\/var\/www\/html\/<\/p>\n\n\n\n<p>We need a copy of the html folder and all subfolders. One issue is that this path also included the wordpress and database backups. These can be quite huge. It helps to exclude these backups.<\/p>\n\n\n\n<pre class=\"wp-block-code .block-code{ overflow-x: auto; }\"><code>cd ..\n\n#Lets make a copy of the site data. Lets also exclude the \n#backups folder and all sub folders.\n\ntar --exclude=\"*\/backups\/*\" -czvf site.tar.gz html\n\n#Just for reference, how big is it?\ndu -h site.tar.gz\n\n#Confirm path\npwd\n\nexit\n\n\n#We are now back in the hosting server\n#Copy the file from the docker webserver to the hosting server\ndocker cp old-wp-server:\/var\/www\/site.tar.gz .\n<\/code><\/pre>\n<\/div>\n\n\n\n<p>Step 2. Copying the database data.<\/p>\n\n\n\n<p>Next, we need to create a copy of the database itself. The database does contain some references regarding the address of the website. These will need handled separately.<\/p>\n\n\n\n<p>First, lets get this copied.<\/p>\n\n\n\n<p>There are a couple of options here. I had access to a PHPmyadmin instance to do things visually. Probably overkill though.<\/p>\n\n\n\n<p>The default MySQL installation has a useful command line utility which can be used in this situation. Especially as it can be done over a ssh session with the server. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#Assuming we are still logged into a ssh session running on the hosting server\n#The following command may take a short while to run,\n#depending on the size of the DB\n\nmysqldump -u root -p database_name > \/backup.sql\n\n\n#Again, as this is moving to another container, it can be pulled back to the hosting server\n\ndocker cp old-SQL-container:\/backup.sql .<\/code><\/pre>\n\n\n\n<div class=\"wp-block-group has-base-background-color has-background has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<p>Step 3. Search\/Replace website references.<\/p>\n\n\n\n<p>At this stage, the database dump file still refers to the old website and if uploaded will cause problems. We need to replace all occurrences to the new (or target) website address. This can be achieved using the <a href=\"https:\/\/askubuntu.com\/questions\/20414\/find-and-replace-text-within-a-file-using-commands\">sed <\/a>command<\/p>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#Replacing the references to the old website\n#with the address of the target website\n\nsed -i 's\/oldwebsite\/newwebsite\/g' backup.sql<\/code><\/pre>\n\n\n\n<p>Step 4. Unpacking the website data.<\/p>\n\n\n\n<p>We are now ready to get the website data from the old site, to the new one, Again, this is a container based movement.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#Lets also get the wordpress copy into the container\ndocker cp .\/site.tar.gz new-wp-server:.\n\n#lets unpack the website data first\ndocker exec -it new-wp-server bash\n\n#unpack the data into the www folder\nmv .\/site.tar.gz \/var\/www\ncd \/var\/www\ntar -xzvf site.tar.gz .\nexit\n#back in the remove server\n<\/code><\/pre>\n\n\n\n<p>Step 5. Preparing the new database.<\/p>\n\n\n\n<p>To deal with the database, i found it easier to dump the original and recreate a blank one ready for import<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#first lets move the database file\ndocker cp backup.sql new-SQL-container:.\n\n#Now lets process it\n\ndocker exec -it new-SQL-container bash\nmysql -u root -p\n#enter password\nDROP wordpress;\nCREATE wordpress;\nexit\n\n#Now import the database info\nmysql -uroot -p &lt; backup.sql\nexit\n\n<\/code><\/pre>\n<\/div>\n\n\n\n<p>Step 6. Try it out.<\/p>\n\n\n\n<p>At this point we need to test it out. use the apporpriate command for getting things up and running. In my case, I was using docker compose.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker compose --profile appropriate-profile up -d<\/code><\/pre>\n\n\n\n<p>In the event things dont work properly, I can leave out the -d switch to view the messages during the startup of the containers for clues.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summarizing some of the steps in moving a website from one address to another without using the &#8220;paid&#8221; tools<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-41","post","type-post","status-publish","format-standard","hentry","category-testing"],"_links":{"self":[{"href":"https:\/\/www.test2.laoku.co.uk\/index.php\/wp-json\/wp\/v2\/posts\/41","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.test2.laoku.co.uk\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.test2.laoku.co.uk\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.test2.laoku.co.uk\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.test2.laoku.co.uk\/index.php\/wp-json\/wp\/v2\/comments?post=41"}],"version-history":[{"count":13,"href":"https:\/\/www.test2.laoku.co.uk\/index.php\/wp-json\/wp\/v2\/posts\/41\/revisions"}],"predecessor-version":[{"id":137,"href":"https:\/\/www.test2.laoku.co.uk\/index.php\/wp-json\/wp\/v2\/posts\/41\/revisions\/137"}],"wp:attachment":[{"href":"https:\/\/www.test2.laoku.co.uk\/index.php\/wp-json\/wp\/v2\/media?parent=41"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.test2.laoku.co.uk\/index.php\/wp-json\/wp\/v2\/categories?post=41"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.test2.laoku.co.uk\/index.php\/wp-json\/wp\/v2\/tags?post=41"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}