compose-website/unit-files/backup@.service
2014-12-02 14:49:33 +00:00

28 lines
804 B
Desktop File

[Unit]
Description=Back up domain data to a git repo and push it out
[Service]
Type=oneshot
ExecStartPre=/bin/bash -euxc ' \
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`; \
/usr/bin/docker run \
--link mysql-%i:db \
--env-file /data/domains/%i/mysql/.env \
indiehosters/mysql \
mysqldump \
--all-databases \
--events \
-u admin \
-p$mysql_passwd \
-h db > /data/domains/%i/mysql/dump.sql; \
fi'
ExecStart=/bin/bash -euxc ' \
echo "Committing everything"; \
cd /data/domains/%i/; \
git add *; \
git status; \
git commit --allow-empty -am"backup %i @ `hostname` - `date`"; \
git push origin master'