Wed. Jan 26th, 2022


Ever marvel how you can again up a web site on Linux? Jack Wallen reveals you ways simple it may be.

Website design. Developing programming and coding technologies.

Picture: scyther5, Getty Photos/iStockphoto

Catastrophe occurs. Or, if catastrophe has but to strike, you may end up in a scenario whereby you must migrate a web site from one server or host to a different. When both factor occurs, what do you do? Panic? No. You observe by way of along with your backup and restore plan.

You’ve got one, proper? 

No?

Okay, let’s repair that. 

I’ll stroll you thru the method of backing up and restoring a web site that’s housed on Linux. Perceive, this course of will not work for each website (as a result of all issues should not equal), however it ought to offer you a basis from which to work.

With that stated, let’s get going.

What you may want

I’ll assume your web site depends upon a MySQL database, runs on Apache, and /var/www/html is your doc root. To make this backup/restore occur, you may want a person with root privileges.

SEE: 40+ open supply and Linux phrases you must know (TechRepublic Premium)

Tips on how to again up your database

First, I’ll show utilizing WordPress. For example our database is wordpressdb. We have now to create a backup of that earlier than we do the rest. You may need to think about placing your website into upkeep mode (so customers aren’t actively on the location and fewer knowledge will probably be written to the database). You possibly can put your WordPress website in upkeep mode with third-party plugins reminiscent of WP Upkeep Mode or SeedProd. 

As soon as your website is in upkeep mode, again up the database by logging into the internet hosting server and issuing the command:

sudo mysqldump wordpressdb > wordpressdb-backup.sql

You may additionally need to add the date to the backup filename, reminiscent of wordpress-backup-DEC302021.sql.

Tips on how to again up WordPress

Now that your database is backed up, it is time to again up the WordPress listing. Let’s assume that listing is /var/www/html/wordpress. To again up that listing, subject the command:

sudo tar -cpvzf wordpress-backup.tar.gz /var/www/html/wordpress

The above choices are:

  • c – create an archive
  • p – protect permissions
  • v – present verbose output
  • z – compress the archive
  • f – create a file

At this level you could have the 2 recordsdata:

  • wordpressdb-backup.sql
  • wordpress-backup.tar.gz

Subsequent, you may need to make a replica of your Apache configuration file. Assuming that file is wordpress.conf, make a replica of it with:

sudo cp /and many others/apache2/sites-available/wordpress.conf ~/wordpress.conf

Lastly, when you’re utilizing SSL certificates in your server, you may need to copy them as properly.

Tips on how to restore WordPress

Okay, it is now time for the restoration. I’ll assume we’re restoring to the identical server. In case you’re restoring to a brand new server, you may want to start out by ensuring you could have all the dependencies put in (the total LAMP stack) with a command like:

sudo apt set up apache2 ghostscript libapache2-mod-php mysql-server php php-bcmath php-curl php-imagick php-intl php-json php-mbstring php-mysql php-xml php-zip -y

Let’s assume you could have every part WordPress requires put in. The very first thing we’ll then do is restore the database with the command:

sudo mysql wordpressdb < wordpressdb-backup.sql

Subsequent, we’ll restore the backup listing to the Apache doc root with:

tar -xzvf wordpress-backup.tar.gz
sudo mv wordpress /var/www/html/

Transfer your apache configuration file with:

sudo mv wordpress.conf /and many others/apache2/sites-available/

Allow the location with:

sudo a2ensite wordpress

You must now be capable of entry the WordPress website as you probably did earlier than. In case you put the location in upkeep mode earlier than you backed it up, you may must take it out of upkeep mode so customers can entry it.

And that is all there’s to backing up and restoring a web site in Linux. In fact, that is very fundamental. If in case you have a way more difficult website, there’ll in all probability be extra steps concerned. Nonetheless, this may no less than offer you a common understanding of how the method works.

Additionally see

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the most recent tech recommendation for enterprise professionals from Jack Wallen.



Source link

By admin

Leave a Reply

Your email address will not be published.