Categories
Wordpress

backup wordpress before upgrading

That’s what it says, but what is the best way to do so..

I use a combinations of Tar (Tape Archive) and WP-Cli (WordPress Command Line Interface)

#!/usr/bin/env bash

D=$(date +'%Y%m%d%H%M%S')
P="/var/www"
S="vasteraskopia.se"

echo "Dumping database to: ${P}/${S}-${D}.sql"
cd ${P}/${S}
wp --allow-root db export ${P}/${S}-${D}.sql


echo "Backing up with tar: ${P}/${S}-${D}.tgz"
cd ${P}
tar --exclude=${S}/wp-content/uploads -zcf ${S}-${D}.tgz ${S}/

By Nimpen J. Nordström

System Developer and Network Security Enthusiast