Skip to content

Instantly share code, notes, and snippets.

@mdpuma
Last active April 20, 2016 17:52
Show Gist options
  • Save mdpuma/0cabfe9092b2822c879cfbcb37842dab to your computer and use it in GitHub Desktop.
Save mdpuma/0cabfe9092b2822c879cfbcb37842dab to your computer and use it in GitHub Desktop.
sync mysql dbs
#!/bin/bash
# install pv, mysql, ssh
# dbs contain list of databases
cat dbs | while read i; do
echo "syncing '$i'"
ssh -n root@178.33.37.57 "mysqldump $i | gzip -c" | pv | gzip -d | mysql $i
done
# clone mysql users privileges
mysqldump mysql --tables user | mysql mysql
#!/bin/bash
DOMAIN=nunta.md
ACCOUNT=admin
IP=46.1.1.1
# create webdomains from stdin
/usr/local/vesta/bin/v-list-web-domains $ACCOUNT shell | grep -vE "DOMAIN|---" | cut -d ' ' -f1 \
| xargs -I{} /usr/local/vesta/bin/v-add-web-domain $ACCOUNT {} $IP
# create maildomains from stdin
/usr/local/vesta/bin/v-list-mail-domains $ACCOUNT shell | grep -vE "DOMAIN|---" | cut -d ' ' -f1 \
| xargs -I{} /usr/local/vesta/bin/v-add-mail-domain $ACCOUNT {}
# create mail accounts from stdin
/usr/local/vesta/bin/v-list-mail-accounts $ACCOUNT $DOMAIN | grep -vE "ACCOUNT|---" | cut -d ' ' -f1 \
| xargs -I{} /usr/local/vesta/bin/v-add-mail-account $ACCOUNT $DOMAIN {} "PASSWORD"
# list mail domains with accounts > 0
/usr/local/vesta/bin/v-list-mail-domains $ACCOUNT shell | grep -vE "ACCOUNT|---" | awk '{ if ($5 > 0) print $0 }' | cut -d ' ' -f1
# list mail accounts from mail domain
/usr/local/vesta/bin/v-list-mail-accounts $ACCOUNT $DOMAIN | grep -vE "ACCOUNT|---" | cut -d ' ' -f1
# create dns domains
/usr/local/vesta/bin/v-list-dns-domains $ACCOUNT | grep -vE "DOMAIN|---" | cut -d' ' -f1 \
| xargs -I{} /usr/local/vesta/bin/v-add-dns-domain $ACCOUNT {} $IP ns1.{} ns2.{}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment