Created
September 17, 2016 00:43
-
-
Save juanpabloprado/2a308d963c9257420279ddb63b5d22bc to your computer and use it in GitHub Desktop.
This file contains 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/bash | |
cd /var/www/html | |
NOW=$(date +%Y%m%d) | |
SQL_FILE=${NOW}_database.sql | |
# Backup database | |
wp db export ../backups/$SQL_FILE --add-drop-table | |
# Compress the database file | |
gzip ../backups/$SQL_FILE | |
# Remove backup files that are a month old | |
rm -f ../backups/$(date +%Y%m%d* --date='1 month ago').gz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment