diff --git a/README.md b/README.md index 20334ba..578448b 100644 --- a/README.md +++ b/README.md @@ -21,5 +21,6 @@ This repository contains miscellaneous scripts used by [Wikimedia Sverige (WMSE) * phabricator-floating-top-bar.user.css - *Stylus CSS for floating top bar in Phabricator.* * google-flip-portrait.user.css - *Stylus CSS for flipping a portrait in google services.* * sites-redirect-test.sh - *Prints the final URL for domains hosted on sites.wikimedia.se to quickly see that redirects work as they should.* +* wp-backup.sh - *Creates a Mysql backup from the config supplied as parameter and compresses it with Bzip2.* When adding a script, also add it to this list with a short description. diff --git a/wp-backup.sh b/wp-backup.sh new file mode 100644 index 0000000..1ec229c --- /dev/null +++ b/wp-backup.sh @@ -0,0 +1,8 @@ +#! /usr/bin/env bash + +host=$(sudo php -r "include('$1'); echo DB_HOST;") +db=$(sudo php -r "include('$1'); echo DB_NAME;") +user=$(sudo php -r "include('$1'); echo DB_USER;") +password=$(sudo php -r "include('$1'); echo DB_PASSWORD;") + +mysqldump --add-drop-table -h $host -u $user --password=$password $db | bzip2 -c | pv -p --timer --rate --bytes > backup-$(date --iso-8601).sql.bz2