2014-11-04 14:27:07 +00:00
|
|
|
[Unit]
|
2015-01-15 16:59:01 +00:00
|
|
|
Description=Back up data from %i
|
2014-11-04 14:27:07 +00:00
|
|
|
|
|
|
|
[Service]
|
|
|
|
Type=oneshot
|
2015-01-15 18:41:47 +00:00
|
|
|
TimeoutStartSec=0
|
2015-01-15 16:59:01 +00:00
|
|
|
EnvironmentFile=/etc/environment
|
|
|
|
ExecStartPre=/usr/bin/docker run --rm -v /opt/bin:/opt/bin ibuildthecloud/systemd-docker
|
2014-12-03 17:08:51 +00:00
|
|
|
ExecStartPre=-/usr/bin/docker kill mysqldump-%i
|
|
|
|
ExecStartPre=-/usr/bin/docker rm mysqldump-%i
|
2014-11-05 12:43:16 +00:00
|
|
|
ExecStartPre=/bin/bash -euxc ' \
|
2014-11-05 17:28:04 +00:00
|
|
|
if [ -d /data/domains/%i/mysql ]; then \
|
|
|
|
echo "Backing up mysql databases for %i"; \
|
|
|
|
mysql_passwd=`cat /data/domains/%i/mysql/.env | cut -d= -f2`; \
|
2014-11-05 12:43:16 +00:00
|
|
|
/usr/bin/docker run \
|
2014-12-03 17:08:51 +00:00
|
|
|
--rm \
|
|
|
|
--name mysqldump-%i \
|
2014-11-05 17:28:04 +00:00
|
|
|
--link mysql-%i:db \
|
|
|
|
--env-file /data/domains/%i/mysql/.env \
|
2015-01-05 16:35:46 +00:00
|
|
|
pierreozoux/mysql \
|
2014-11-05 12:43:16 +00:00
|
|
|
mysqldump \
|
|
|
|
--all-databases \
|
|
|
|
--events \
|
2014-12-03 17:08:33 +00:00
|
|
|
-uadmin \
|
2014-11-05 17:28:04 +00:00
|
|
|
-p$mysql_passwd \
|
|
|
|
-h db > /data/domains/%i/mysql/dump.sql; \
|
2014-11-05 12:43:16 +00:00
|
|
|
fi'
|
|
|
|
|
|
|
|
ExecStart=/bin/bash -euxc ' \
|
2015-01-19 13:25:32 +00:00
|
|
|
/bin/docker run \
|
2015-01-15 16:59:01 +00:00
|
|
|
--rm \
|
2015-01-19 14:00:50 +00:00
|
|
|
--name backup-%i \
|
2015-01-15 16:59:01 +00:00
|
|
|
-h backup.container \
|
|
|
|
-v /root:/root \
|
|
|
|
-v /data/domains/%i:/backup pierreozoux/duplicity \
|
|
|
|
--encrypt-key ${ENCRYPT_KEY} \
|
|
|
|
/backup \
|
|
|
|
sftp://${BACKUP_DESTINATION}/%i'
|
2015-01-14 13:43:12 +00:00
|
|
|
|