This is a basic question.. I am trying to write a very simple script to backup my wordpress database every hour..
#!/bin/sh
#
# This script do an hourly backup of WordPress DB
# Set global parameters
WPROOT=/home/mydomain/public_html
WPBKUPS=/usr/home/mydomain/db_backups
SITEURL=`wp option get siteurl | awk -F/ '{print $3}'`
BKNAME="$WPBKUPS/`date +%Y-%m-%d.%H%M`-$SITEURL"
# change directory
#cd $WPROOT
#cd /usr/local/www/production/httpdocs/wpsite
wp db export --allow-root - | gzip -9 > $BKNAME.sql.gz
# Stop build-up of loads of older files with exec rm \o/
find "$WPBKUPS" -mtime +1 -exec rm {} \;
Question 1: should I be using the option --add-drop-table? what is the difference with my code
Question 2: at the moment the script reside insite the wproot.. how can I change the script so that the script is not in the public facing directory?
Thank you