28 lines
804 B
Desktop File
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'
|