Skip to content

Instantly share code, notes, and snippets.

@mmilosheski
Created March 19, 2018 12:00
Show Gist options
  • Save mmilosheski/8415ed9cd42bbaa3d15a3370e5211452 to your computer and use it in GitHub Desktop.
Save mmilosheski/8415ed9cd42bbaa3d15a3370e5211452 to your computer and use it in GitHub Desktop.
#!/bin/bash
# wp-cli is mandatory in order this script to work
# call the script manually by running ./backup.sh
# or add the script to the crontab to run periodically
# it will create a dump of your database and .zip of your wp-content folder
cd /var/www/wordpress/ # path to your site
# Backup database
wp db export --database=staging backups/`date +%Y%m%d`_database.sql --add-drop-table
# Backup uploads directory
tar -zcf backups/`date +%Y%m%d`_uploads.tar.gz wp-content/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment