Skip to content

Instantly share code, notes, and snippets.

@Arvoreen
Last active March 28, 2019 02:32
Show Gist options
  • Save Arvoreen/fd747dddcf1a5938216f0330d0ffa2b1 to your computer and use it in GitHub Desktop.
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
#!/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