Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Mte90
Created July 7, 2020 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mte90/167be9fedb4c133f66b546a3fd699ae3 to your computer and use it in GitHub Desktop.
Save Mte90/167be9fedb4c133f66b546a3fd699ae3 to your computer and use it in GitHub Desktop.
Backup to webdav files and WordPress DB
#!/bin/sh
today=$(date +"%Y-%m-%d")
path=$(date +"%Y/%m/%d")
rm -rf ./backups
mkdir ./backups
tar --exclude='./public_html/cgi-bin' --exclude='*.zip' --exclude='./public_html/wp-content/cache' -zcvf ./backups/$today.tar.gz ./public_html > /dev/null
./wp db export --add-drop-table --path=./public_html/ - | gzip > "./backups/$today.sql.gz"
curl --user "user:pass" -T "./backups/$today.tar.gz" "https://domain.com/remote.php/webdav/folder/$path/domain-$today.tar.gz"
curl --user "user:pass" -T "./backups/$today.sql.gz" "https://domain.com/remote.php/webdav/folder/$path/domain-$today.sql.gz"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment