Last active
December 12, 2015 02:58
-
-
Save oterox/4702468 to your computer and use it in GitHub Desktop.
bash script to backup WP
It generates 3 files:
- sql dump
- theme folder backup
- wp-content folder backup
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 | |
echo $* | |
CURRENT_DATE=`date '+%Y%m%d-%Hh%M'` | |
WP_DATABASE=database_name | |
WP_FOLDER=wpfolder | |
WP_THEME=themefoldername | |
WP_CONTENT_PATH=/var/www/"$WP_FOLDER"/ | |
WP_THEME_PATH=/var/www/"$WP_FOLDER"/wp-content/themes/ | |
#Backup database | |
mysqldump --add-drop-table -u myuser -pmypass "$WP_DATABASE" > "$CURRENT_DATE"-"$WP_DATABASE".sql | |
#Backup Theme excluding caches and git files | |
tar --exclude-caches --exclude ".git/" -czf ${CURRENT_DATE}-${WP_FOLDER}-${WP_THEME}-theme.tar.gz --directory "$WP_THEME_PATH" "$WP_THEME$ | |
#Backup Content excluding caches and git files | |
tar --exclude-caches --exclude ".git/" -czf ${CURRENT_DATE}-${WP_FOLDER}-content.tar.gz --directory "$WP_CONTENT_PATH" wp-content/ | |
#TO-DO: compress all and upload to ftp server | |
#TO-DO: option for sending through email |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment