Commit e5bec266 authored by Pepijn Boers's avatar Pepijn Boers
Browse files

Add systemd scripts

parent 7adcc1db
......@@ -53,7 +53,7 @@ location /dnt/ {
}
```
Since the second server works from a subdirectory, we have to add this line to matomo's `config/config.ini.php` file to make sure the respones redirect clients to `/dnt`:
Since the second server works from a subdirectory, we have to add this line to matomo's `config/config.ini.php` file to make sure responses to clients are redirected to `/dnt`:
```
[General]
......@@ -88,6 +88,8 @@ location = /mirror {
```
The complete nginx config file can be found in [here](nginx/nginx.conf).
In order to let matomo know it is behind a reverse proxy we have to add some lines to the `config/config.ini.php` file in both installations, see this [faq](https://matomo.org/faq/how-to-install/faq_98/). Also we can assume our request are secure, because the connection client-proxy is over https, see illustration below.
<img src="img/setup/reverse_proxy.png" alt="Reverse proxy setup" width="650"/>
......
These scripts are called by service units:
- archive-matomo.service
- backup-matomo.service
- db-backup.service
docker exec -i core_app_1 /var/www/html/console core:archive --url=matomo.science.ru.nl
docker exec -i core_app-dnt_1 /var/www/html/console core:archive --url=matomo.science.ru.nl
docker exec -i core_db_1 mysqldump --hex-blob --single-transaction --quick --lock-tables=false --password="" matomo | gzip > /var/home/core/backups/backup.sql.gz
docker exec -i core_db-dnt_1 mysqldump --hex-blob --single-transaction --quick --lock-tables=false matomo | gzip > /var/home/core/backups/backup_dnt.sql.gz
tar -zcvf /var/home/core/backups/backup.tar.gz /var/home/core/data/app/plugins /var/home/core/data/app/config
tar -zcvf /var/home/core/backups/backup_dnt.tar.gz /var/home/core/data/app_dnt/plugins /var/home/core/data/app_dnt/config
Systemd units located on the server at /etc/systemd/system/.
Useful commands:
systemctl enable <name>
systemctl daemon-reload
systemctl start <name>
\ No newline at end of file
[Unit]
Description=Runs matomo archive
Wants=archive-matomo.timer
[Service]
ExecStart=/bin/sh /var/home/core/scripts/archive-reports
[Install]
WantedBy=multi-user.target
[Unit]
Description=Run archive matomo every hour.
Requires=archive-matomo.service
[Timer]
Unit=archive-matomo.service
OnCalendar=*-*-* *:00:00
[Install]
WantedBy=timers.target
[Unit]
Description=Runs mysql backup
Wants=backup.timer
[Service]
ExecStart=/bin/sh /var/home/core/scripts/backup-db
[Install]
WantedBy=multi-user.target
[Unit]
Description=Run backup mysql every 1 night
Requires=db-backup.service
[Timer]
Unit=db-backup.service
OnCalendar=*-*-* 02:00:00
[Install]
WantedBy=timers.target
[Unit]
Description=Runs matomo backup
Wants=backup-matomo.timer
[Service]
ExecStart=/bin/sh /var/home/core/scripts/matomo-backup
[Install]
WantedBy=multi-user.target
[Unit]
Description=Run backup matomo every night at 4.
Requires=matomo-backup.service
[Timer]
Unit=matomo-backup.service
OnCalendar=*-*-* 04:00:00
[Install]
WantedBy=timers.target
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment