Skip to content

Instantly share code, notes, and snippets.

@sergixnet
Last active May 28, 2018 11:05
Show Gist options
  • Save sergixnet/696b4ce30d3ade3cf34f7f28a35620ba to your computer and use it in GitHub Desktop.
Save sergixnet/696b4ce30d3ade3cf34f7f28a35620ba to your computer and use it in GitHub Desktop.
#!/bin/bash
# Creates a backup of a WordPress instalation, files and database with WP-CLI
# Go to the root directory
cd htdocs
# Backup files of the root site
tar --exclude='./.git' -czvf "backup-$(date +%Y%m%d%H%M%S).tar.gz" .
# Backup of the database
wp db export "backup-db-$(date +%Y%m%d%H%M%S).sql"
echo Backup files created OK
echo Now you should download and remove the files from the server
echo Bye!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment