Last active
March 28, 2019 02:32
-
-
Save Arvoreen/fd747dddcf1a5938216f0330d0ffa2b1 to your computer and use it in GitHub Desktop.
Backup script -- runs on hosting site, assumes already setup aliases for wp-cli
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 | |
PATH=$PATH:/usr/local/bin | |
# Loop through all sites, | |
echo "Starting backups @$(date)" | |
for site in $(cat $HOME/etc/sites); do | |
cd $HOME/backups | |
BKDIR="$HOME/backups/$site/" | |
if [ ! -d "$BKDIR" ]; then | |
#make sure new directory exists | |
mkdir -p $BKDIR | |
fi | |
echo "Starting backup for $site" | |
cd $BKDIR | |
wp @$site db export --add-drop-table - |gzip > database.sql.gz | |
tar czf wordpress.tgz -C /var/www/html $site | |
echo "Finished backukp for $site" | |
echo | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment