Automated script to backup wordpress daily or restore from backup
Shell
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
README.md
backupWP.sh
cloudflare.sh
functions.sh
restoreWP.sh
setup.sh

README.md

WordpressRestore v1.0

Automated script to backup wordpress daily or restore from backup

Pre-requisites

  1. Wordpress site (to backup and restore)
  2. Dropbox account (to save backups and restore from)
  3. Optional Cloudflare account (with token key) if you wish to update DNS
  4. Account with sudo access on the Ubuntu box you're at
    4.1 To create non-root Sudo account refer to http://do.co/2fN6VxN
    4.2 To execute sudo without password prompr refer to http://bit.ly/2lXtmCu

Assumptions

  1. Wordpress site is stored on Ubuntu 16.04 (only tested versions, both on AWS and DigitalOcean)
  2. Database is MYSQL and running on the same machine (localhost)
  3. Apache config files are ALL in /etc/apache2--no certs stored elsewhere except /etc/Letsencrypt

To Backup Wordpress:

git clone https://github.com/keithrozario/WordpressRestore/
cd WordpressRestore
chmod +x *.sh
./setup.sh --dropboxtoken [xxx] --enckey [xxx] --wpdir [xxx] --wpconfdir [xxx]

  • --dropboxtoken DROPBOX ACCESS TOKEN [MANDATORY]
    The access token for your dropbox account, refer to http://bit.ly/2iT95IT to get one
  • --enckey ENCRYPTION KEY FOR BACKUPS [MANDATORY]
    A user supplied encryption key to encrypt backups (all filed uploaded to backup dir are encrypted)
  • --wpdir WORDPRESS DIRECTORY [OPTIONAL]
    Directory of the Wordpress installations, defaults to /var/www/html if not supplied
  • --wpconfdir WORDPRESS CONFIGURATION DIRECTORY [OPTIONAL]
    Directory of the Wordpress wp-config.php file, defaults to Wordpress Directory if not supplied

*setup.sh automatically sets up backups to run once a day, uploading relevant files to Dropbox Directory
*all files are encrypted with --enckey, stored in /var/.enckey. This file isn't backed-up. Don't lose the encryption key!!

To Restore Wordpress:

git clone https://github.com/keithrozario/WordpressRestore/
cd WordpressRestore
chmod +x *.sh
./restoreWP.sh --dropboxtoken [xxx] --enckey [xxxx] --aprestore [x] --domain [xxx] --cfemail [xxx] --cfzone [xxx] --cfkey [xxx] --cfrecord [xxx] --dbrootpass [xxx]

  • --dropboxtoken DROPBOX_ACCESS_TOKEN [MANDATORY]
    The access token for your dropbox account, refer to http://bit.ly/2iT95IT to get one
  • --enckey ENCRYPTION_KEY_FOR_BACKUPS [MANDATORY]
    A user supplied decryption key to decrypt backups (all files uploaded to backup dir are encrypted)
  • --aprestore APACHE Restore Flag [OPTIONAL]
    Optional: Set to 1 to restore Apache from backup, do not call to allow script to build from scratch
  • --domain Website Domain [CONDITIONAL]
    Conditional:Set to domain (e.g. www.example.com) if aprestore is not set
  • --cfemail CLOUDFLARE_EMAIL_ADDRESS [OPTIONAL]
    Optional: Email Address for your cloudflare account
  • --cfzone CLOUDFLARE_URL_ZONE [OPTIONAL]
    Optional: Cloudflare zone (e.g. keithrozario.com)
  • --cfrecord CLOUDFLARE_RECORD [OPTIONAL]
    Optional: Cloudflare record to update (e.g. www.keithrozario.com)
  • --cfkey CLOUDFLARE_ACCESS_TOKEN [OPTIONAL]
    Optional: Cloudflare access token, refer to http://bit.ly/2hTadAg to get one
  • --prodcertProduction Certificate Flag [OPTIONAL]
    Optional: set to 1 for production certificate from Let's Encrypt, 0 for non-prod, leave blank to skip Let's encrypt
  • --dbrootpass DATABASE_ROOT_PASSWORD [OPTIONAL]
    The password for root on the database you're about to create, script will generate random pass if not supplied with one

*if --prodcert is set to 1, Cronjobs will be created for "letsencrypt renew" to run twice a day (6am and 11pm)
*if --prodcert is set to 0, lets encrypt will call test certificates, cronjobs will still be created
*if --prodcert is not set, let's encrypt step is bypassed, no cronjobs created, or certificates called

Special Thanks

Thanks to Andrea Fabrizi for the awesome DropboxUploader script
Thanks to Ben Kulbertis for the awesome Cloudflare update script
Thanks to Peteris.Rocks for his/her awesome work on the Unattended Wordress Install