Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

WordPress – Backup & Restore

Posted on January 28, 2016February 22, 2016 By David Kittell

I have this in these two posts (CentOS – WordPress Install and Ubuntu – WordPress Install) but thought it may be best to create a separate post to help focus on this process.

After writing this post I came across a site that I do not have SSH/CLI access to so I needed to have another option. If you do not have SSH/CLI access it’s best to use the process on PHP – WordPress Backup (MySQL & Files).

Backup

The purpose of this step is to have a quick repeatable command to backup and restore a database.
Log in as your username with website rights (not root) and run this command
For our purposes the values we use can be changed to suit your needs:

  • Database: Site1WPDB
  • Username: Site1WPUSR
  • Password: Site1WPUSRPWD
echo '[mysqldump]'> ~/.my.cnf;
echo 'user=Site1WPUSR'>> ~/.my.cnf;
echo 'password=Site1WPUSRPWD' >> ~/.my.cnf;
chmod 0600 ~/.my.cnf
mysqldump -u Site1WPUSR Site1WPDB > ~/WordPress_DB_Backup_`date +"%m-%d-%Y_%I-%M-%S"`.sql
tar -zcvf WordPress_Site_Backup_`date +"%m-%d-%Y_%I-%M-%S"`.tar.gz /var/www/html

Restore

Make sure you modify the date of the file to what you want to restore from.

mysql -u Site1WPUSR Site1WPDB < ~/WordPress_DB_Backup_08-27-2015.sql
Originally Posted on January 28, 2016
Last Updated on February 22, 2016
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Code UNIX Shell Scripts WordPress

Post navigation

Previous post
Next post

Related Posts

Windows CMD – Disk Partition and Format with DiskPart

Posted on December 22, 2016December 22, 2016

NOTE: This is not put in code as it can be VERY difficult reverse the process below. ONLY do this if you have a clue of what you are doing . This process has been tested on a USB Hard Drive, Thumb Drive, and Physical (Internal to computer) Hard Drive…

Read More

Unix Time Conversion

Posted on October 23, 2013October 26, 2015

When integrating various systems you sometimes need to convert DateTime values to an Integer, the code samples below will be helpful Public Function UnixToDateTime(ByVal strUnixTime As String) As Date UnixToDateTime = DateAdd(DateInterval.Second, Val(strUnixTime), #1/1/1970#) End Function Public Function DateTimeToUnix(ByVal dteDate As Date) As String DateTimeToUnix = System.Convert.ToInt64((dteDate – New DateTime(1970,…

Read More

PowerShell – Start / Stop IIS Website and Application Pool

Posted on November 16, 2015

clear Function Load-WebAdmin { $webAdminModule = get-module -ListAvailable | ? { $_.Name -eq "webadministration" } If ($webAdminModule -ne $null) { import-module WebAdministration } } # Variables – Start $siteName = $args[0] # "default web site" $appPoolName = $args[1] # "DefaultAppPool" $action = $args[2] # 1 for stop, 0 for start…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
  • Open On Screen Keyboard (OSK)
  • SQLite - Auto-Increment / Auto Generate GUID
©2025 David Kittell | WordPress Theme by SuperbThemes