Welcome, Guest: Join Kenyans247 Log In!

Stats: 291 Members, 13,310 topics and 65 posts Date:  Tuesday 27 October 2020 at 11:41 AM
Popular & Trending NewestFeatured Links ClassifiedDirectoryLivescoresLive Kenyan TVLive Kenyan Radio Follow Us Like Us

About Us Terms & Conditions Privacy Policy FAQ's Disclaimer Copyright Contact Us Advertise With Us Download K247 APP Marketplace Moderator Policy We Are Hiring Kenya Radio and TV Stations Listen and Watch Live Letter From the C.E.O Kenya Radio Stations Live Kenya TV Stations Live Kenya - Newspapers and News Sites and popular blog Forum Rules

Make a Backup Copy of your Production WordPress Blog on Ubuntu

Kenyans247 / Science/Technology / Programing / Make a Backup Copy of your Production WordPress Blog on Ubuntu

93 people viewed

How To Get License To Make A Film/take Commercial Still Photograph In Kenya How You Can Make A Million From An Acre Of Watermelons Restore Mysql Database From A Backup File How To Make A Facetime Call With Siri
(Go Down) (» Reply topic)
Make a Backup Copy of your Production WordPress Blog on Ubuntu by Kenyans247(1): Sun 22, March, 2020 09:27am
You’ve just thought of a great new layout for your blog… but making changes to your blog while visitors are accessing it is generally a bad idea, especially if you are running an ad-supported blog. This How-To shows you the list of steps you need to take to get a copy of your production WordPress blog copied down to your local Ubuntu machine. (Should work for any debian linux)


First, we’ll need to make a copy of your current WordPress blog. I’m going to assume you have access to the console at your hosting provider, or they at least have some type of backup provided for you. If you get your backup files a different way you can skip that step.

For a blog, we’ve got both the WordPress installation as well as the database, where the text of all your posts are actually stored. If you’ve uploaded images or files, they will be in your wordpress folder structure, so we really need both.

1) Let’s get a backup of the database first. Connect to the server via SSH and run the following command:

mysqldump -uUSERNAME -pPASSWORD -hSERVER DATABASENAME > dbbackup.bak

Naturally you’ll want to substitute the uppercase text for the correct values on your installation.

2) Make a backup of the file structure:

tar -cf sitebackup.tar SITEROOTDIRECTORY

You’ll want to substitute the uppercase text for the root directory of your site.

3) Copy the files down to your local Ubuntu machine. This can be done via scp, ftp, or however you feel like it. I’ll leave that up to you.

4) Make sure you have apache, php and mysql installed. If you don’t, you can consult the other how-to guides on this site, or just type in the following commands at a terminal prompt:

sudo apt-get install apache2

sudo apt-get install php5

sudo apt-get mysql-server

sudo apt-get php5-mysql

sudo /etc/init.d/apache2 restart

5) We need to create a database and import the original database that we backed up. Navigate to the folder that you downloaded the files to and run these commands:

mysqladmin create DATABASENAME

mysql -uroot DATABASENAME < dbbackup.bak

6) Make our local webserver point to the copy of WordPress we got off the production server. First, we’ll want to extract the tar archive that we created. You can do that however you want, but I prefer the command line. There is a utility built into Ubuntu to allow you to do so graphically if that’s the way you like to do it.

tar xvf sitebackup.tar

This will produce a directory structure similar to the one on the server you were on. We’re going to imagine that your site root directory is now in /home/username/wordpress/ for the purposes of this article. If you’ve extracted it elsewhere, then substitute accordingly. We need to add in the alias into apache, so open up the following file:

/etc/apache2/conf.d/alias

You’ll want to paste in these lines, and adjust the paths according to your system and the /directory you want the test blog to be available on.

Alias /wordpress /home/username/wordpress

Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all


7) If you are using Permalinks, you’ll want to duplicate the same thing locally, and will need to enable mod_rewrite:

ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load

8) Now we’ll need to edit the wp-config file to point to the local database. If you’ve been following along, these settings should work for you once you substitute the database name.

// ** MySQL settings ** //
define(‘WP_CACHE’, false); //Added by WP-Cache Manager
define(‘DB_NAME’, ‘DATABASENAME’); // The name of the database
define(‘DB_USER’, ‘root’); // Your MySQL username
define(‘DB_PASSWORD’, ”); // …and password
define(‘DB_HOST’, ‘localhost’); // …and the server MySQL is running on

9) If you are using the using WP-Cache caching module, navigate to your blog root directory and run these commands:

rm wp-content/advanced-cache.php

ln -s wp-content/plugins/wp-cache/wp-cache-phase1.php wp-content/advanced-cache.php

rm wp-content/cache/*

chmod -R 777 *

10) One final thing left to do. The data in the database still has the wrong URL for your blog. The easiest way to fix this is by running a SQL statement against the database. Create a new text file named fixsettings.sql, copy the following lines into it, substituting your own IP address for localhost if you want other people to connect to you:

update wp_options set option_value=’http://localhost/wordpress/’ where option_id=1;
update wp_options set option_value=’http://localhost/wordpress/’ where option_id=40;

Now we’ll import that into the database:

mysql -uroot < fixsettings.sql

Note that you should keep that file around, because any time you want to update your local copy with the latest blog posts, all you have to do is import the database backup file, and then re-run this fixsettings.sql file to make it point locally again. Definitely makes things a lot simpler, and you can eventually schedule a cron job to backup your production blog and pull it into your local machine on a schedule.

Now you should be able to navigate to http://localhost/wordpress/wp-admin/ and login with your regular username. You’ve now got a development copy of your blog!

https://www.howtogeek.com/howto/ubuntu/make-a-backup-copy-of-your-production-wordpress-blog-on-ubuntu/

0 Shares 0 Like •

(» Go Up)

You must Sign in or Sign Up to post content

For you to post content on this website you have to log in or register, it only take few minute to create account

Go Up

Recommended for you

How You Can Make A Million From An Acre Of Watermelons How To Make A Reverse Call On Safaricom Can Masturbation Ever Make A Man Infertile Or Have Low Sperm Count? Real Madrid Will Reportedly Make A £150m Bid For Manchester United Midfielder Pa

Currently: 1 guest(s) reading this article

Sections: Family, K247 Intelligence, Kenyans247 ads, Diaspora, Health, Building/Architecture, Art, Graphics & Video, Technology Market, Universities, Computers, Jokes Etc, Gossip, K247 TV, Poetry, Emojipedia, Burundi Forum, Ugandan Forum, Somalia Forum, Rwanda Forum, South Sudan Forum,

About Us | Terms & Conditions | Privacy Policy | FAQ's | Disclaimer | Copyright | Contact Us | Advertise With Us | Download K247 APP | Marketplace | Moderator Policy | We Are Hiring | Kenya Radio and TV Stations Listen and Watch Live | Letter From the C.E.O | Kenya Radio Stations Live | Kenya TV Stations Live | Kenya - Newspapers and News Sites and popular blog | Forum Rules | Featured LinksFollow Us on TwitterLike Us on Facebook

Kenyans247 - Copyright © 2019 - 2020 Sande Kennedy. All rights reserved. See How To Advertise.
Disclaimer: Every Kenyans247 member is solely responsible for anything that he/she posts or uploads on Kenyans247.