How to backup the Apache config file

UpdraftPlus and other WP backup solution’s safeguards the work you have performed in WordPress. The Apache configuration files are left out. When disaster strikes, access to the Apache config files is invaluable. This might save you hours and perhaps days of downtime and frustration.

 

Automate the process

Below is the command listed one by one.
A shell script that runs once a month from Cron would automate this.
With TextExpander could you run this command sequence from your PC, Mac, iPhone and iPad as a snippet. To distinguish and automatically sort the backups the folders and filenames start with today’s date in the form: year-month-day

 

Save the backup files in a single folder

Create a folder you can access with SFTP and SCP. Then it’s easier to move the backup offsite. Either to your PC or another server or service. If you also choose to keep a local backup on the WP-JeOS server remember to change permissions on the file and folders. The bad guys would just love access to your SSL-certificates!

cd /home/ubuntu/
mkdir 20160627-backup-wp-jeos
cd 20160627-backup-wp-jeos

Now we are ready to start the work creating a backup of the Apache config files.

Backing up SSL certificates

Create a backup of the certificates

sudo zip -r 20160627-etc-ssl-certs-.zip /etc/ssl/certs/*.*

Create a backup of the private certificates
First become root

sudo su

Then create the zip file:

sudo zip -r 20160627-etc-ssl-private-.zip /etc/ssl/private/*.*

Go back to the user ubuntu

exit

 

Backing up Apache main config file

You have appropriately modified the main Apache config file to make the .htacces file work correctly.

sudo zip 20160627-etc-apache2-apache2-conf.zip /etc/apache2/apache2.conf

Backing up the virtual hosts config files

The virtual hosts configuration files for each and every WordPress site might take much work to re-create when disaster strikes. A backup is a real time saver. The .conf file contains the path to your SSL-certificates, specifies the filename of your error logs and access logs and info about the root folder of WordPress.

sudo zip -r 20160627-etc-apache2-sites-available-.zip /etc/apache2/sites-available/*.*

Backup of the Apache config files completed. Now create a TextExpander snippet and perhaps a batch job to perform this fast next time you modify them. A cron job based on the bash script would further automate.

Manually backing up WP-JeOS

When you are at it, backing up the rest of WP-JeOs is easy. Sometimes backups are un-restorable. It could be many reasons for that. Having backups created with different solutions could be wise.

Backing up the file structure

When you have many websites creating a zip-file of the structure is done with this command. Beware. The zip-file could end up to being massive.

sudo zip -r 20160627-var-www-.zip /var/www/

A real timesaver when you need to migrate the whole server. It would usually take less time than restoring one site at a time with UpdraftPlus. Keep in mind that WP-CLI and WordShell are great tools when migrating, creating backups and restoring. WordShell has an excellent integrated backup solution.

Backing up databases

Since we run Amazon RDS MySQL, backup of the databases is less critical. Amazon automatically creates database backups for you. Use the RDS control panel to configures database backups. Modify to fit your needs. Eventually, the RDS backups are overwritten. If it takes months to the problem, corruption or whatever goes wrong is detected. Then a local offsite backup is the only thing that can come to your rescue. Creating backups with free software is easy. Try these:

  • MySQL Workbench
  • Sequel Pro
  • Navicat

 

 

Move the backup offsite

Backup files on a server that you can not access are worthless. Copy or move the backup offsite to another server or service like DropBox, Google Drive or Amazon S3.  You never know what’s ahead.

Verify the backup

Download the backup to your PC. Unzip the files to verify that the zip files contains the intended content.

Restore to a local VPS

VmWare is a great tool. Test that you can regenerate the server to a new VPS running on your PC. VmWare is a user-friendly tool for running Ubuntu on you local workstation. Restoring backups requires practice. It could occur that you are unable to restore a backup. The backup might be incomplete or corrupt. You could run into unforeseen problems when restoring backups. There might be a 3. party plugins or locked software that requires a particular IP to work. Certificates that is locked to a certain environment. It could be many obstacles occurring that you could not foresee or has forgotten. Usually, disaster recovery is a very stressful situation that in the long term is damaging to your health. Practice enables you to perform migration faster and with less wear and tear on your health.

Protect the backup

If you keep backups on the WP-JeOs, then you should change the permissions to the files and folders. The backup contains your passwords, SSL-certs and lots of valuable stuff that the bad guys just would love to access.