Skip to content

Instantly share code, notes, and snippets.

@serguk0
Last active January 28, 2020 21:09
Show Gist options
  • Select an option

  • Save serguk0/d3742e853134eb6934953c8647a25f44 to your computer and use it in GitHub Desktop.

Select an option

Save serguk0/d3742e853134eb6934953c8647a25f44 to your computer and use it in GitHub Desktop.
#!/bin/bash
SITE_PATH="/var/www/v2/"
DATE=`date +%Y-%m-%d-%H-%M-%S`
BKP_PATH="/home/sdlab/bkp"
TMP_PATH="$BKP_PATH/$DATE"
mkdir $TMP_PATH $TMP_PATH/{conf,site,db}
cp -a /etc/{nginx,php,mysql,letsencrypt} $TMP_PATH/conf
rsync -azP --exclude=wp-content/cache --exclude=wp-content/uploads --exclude=wp-snapshots --exclude=wp-content/uploads --exclude=*.zip $SITE_PATH $TMP_PATH/site
/usr/local/bin/wp db export --path=$SITE_PATH --allow-root $TMP_PATH/db/$DATE.sql
cd $TMP_PATH
tar -cpvzf $BKP_PATH/wp_backup-$DATE.tar.gz .
rm $TMP_PATH -rf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment