Created
August 11, 2017 16:35
-
-
Save freretuc/aec2ca02839b2dbe8f8a3a26598574f6 to your computer and use it in GitHub Desktop.
mysqldump + duplicity on swift container
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Delete old dumps | |
find /var/www/.backup/ -type f -exec rm -v {} \; | |
##### | |
DATE=`date +"%y%m%d_%Hh%M"` | |
DB_FILE=/var/www/.backup/dump.${DATE}.sql | |
DB_BASE=database | |
DB_USER=dbuser | |
DB_PASS=dbpassword | |
# mysqldump | |
mysqldump --opt --user=${DB_USER} --password=${DB_PASS} ${DB_BASE} > ${DB_FILE} | |
# gzip for limit space | |
gzip $DB_FILE | |
########## | |
src="/var/www/" | |
dest="swift://container-name" | |
export PASSPHRASE="verylongpassphrase" | |
# swift objets working well with ovh.net | |
export SWIFT_USERNAME="container-username" | |
export SWIFT_PASSWORD="container-password" | |
export SWIFT_AUTHURL="https://auth.cloud.ovh.net/v2.0/" | |
export SWIFT_AUTHVERSION="2" | |
export SWIFT_TENANTNAME="container-tenantname" | |
export SWIFT_REGIONNAME="container-region" | |
# send the backup to the container | |
/usr/bin/duplicity --verbosity notice --progress --asynchronous-upload --cf-backend swift --volsize 100 "$src" "$dest" | |
# delete old backups (> 1wk) | |
/usr/bin/duplicity remove-older-than 1W --force "$dest" | |
# !! remove all shared informations | |
unset PASSPHRASE SWIFT_USERNAME SWIFT_PASSWORD SWIFT_AUTHURL SWIFT_AUTHVERSION SWIFT_TENANTNAME SWIFT_REGIONNAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment