Last active
February 20, 2017 20:30
-
-
Save cee-chen/4037d8dcd5bca30145ab954c0208b918 to your computer and use it in GitHub Desktop.
WordPress backup script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Automatically create WordPress database backups every week | |
# Delete old backups | |
cd /home/protected | |
echo "Deleting backups older than 30 days..." | |
find ./ -mtime +30 -type f -name '*.sql.gz' -print -delete | |
# Create the backup | |
now=$(date +"%Y_%m_%d") | |
echo "Saving database backup $now.sql..." | |
cd ../public/ | |
wp db export $now.sql | |
mv $now.sql ../protected/ | |
cd ../protected/ | |
gzip $now.sql | |
# echo "WordPress DB backup saved!" | |
# WordPress prints its own success message. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment