Created
February 2, 2018 06:15
-
-
Save fumikito/2a2c7bbaa103e83ef7965b507ab748b5 to your computer and use it in GitHub Desktop.
Backup statics of WordPress
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
# | |
# Backup WordPress contents. | |
# | |
set -e | |
# Move to WordPress dir | |
cd /var/www/wordpress | |
# Remove if exists. | |
if [ -f wp-content/backup.tar.gz ]; then | |
rm wp-content/backup.tar.gz | |
fi | |
if [ -d wp-content/backup.folder ]; then | |
rm -rf wp-content/backup.folder | |
fi | |
# Make directory | |
mkdir -p wp-content/backup.folder/ | |
# Backup database. | |
/usr/local/bin/wp db export wp-content/backup.folder/wordpress_db.sql --add-drop-table | |
# Copy upload folder | |
cp -r wp-content/uploads wp-content/backup.folder/uploads | |
echo "Uploaded files copied" | |
# Copy plugin folder | |
cp -r wp-content/plugins wp-content/backup.folder/plugins | |
echo "Plugins copied" | |
# Zip archive | |
cd wp-content | |
tar czf backup.tar.gz backup.folder | |
echo "Zip Created." | |
# remove directory | |
rm -rf backup.folder | |
echo "Done."; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment