This commit is contained in:
DoTheEvolution
2021-06-06 11:53:24 +02:00
parent 5d6a78b32a
commit 139f299fe5
+42 -39
View File
@@ -8,13 +8,12 @@
Ticketing system. Ticketing system.
* [Official site](https://zammad.org/) * [Official site](https://zammad.org/screenshots)
* [Github](https://github.com/zammad/zammad) * [Github](https://github.com/zammad/zammad)
* [DockerHub](https://hub.docker.com/r/zammad/zammad-docker-compose) * [DockerHub](https://hub.docker.com/r/zammad/zammad-docker-compose)
Zammad is a modern, open source, good looking web base Zammad is a modern, open source, good looking web base
helpdesk/customer support system. helpdesk/customer support system.<br>
Written in Ruby. This deployment uses PostgreSQL for database Written in Ruby. This deployment uses PostgreSQL for database
powered by elasticsearch, with nginx for web server. powered by elasticsearch, with nginx for web server.
@@ -69,10 +68,11 @@ This brings a lot of files and folders and everything is pre-prepared.<br>
We are not touching the compose file.<br> We are not touching the compose file.<br>
Changes are done only to the `docker-compose.override.yml` and the `.env` file. Changes are done only to the `docker-compose.override.yml` and the `.env` file.
In this case we override port, network and backup locations.<br> I prefer to store backups as bind mounts rather than volumes,
I prefer backups as bind mounts rather than volumes, as volumes can get destroyed by a simple `docker-compose down -v`
which can get destroyed by simple `docker-compose down -v` that can popup in terminal history if used before, and be run by accident.
that can popup in terminal history, if used before, and be run by accident.
So here we override backup locations and join it to reverse proxy network.<br>
`docker-compose.override.yml` `docker-compose.override.yml`
```yml ```yml
@@ -132,11 +132,11 @@ ticket.{$MY_DOMAIN} {
* Setup admin email and password. * Setup admin email and password.
* Organization name and domain - System URL. * Organization name and domain - System URL.
* Email notifications, using smpt. It needs domain set, * Email notifications, using smpt. It needs domain set,
wont work with just localhost wont work with just localhost.
* Setup email channel. * Setup email channel.<br>
This should be an email address where any email received This should be an email address where any email received
will create an unassgnied ticket in zammad and sender will be added to users.<br> will create an unassgnied ticket in zammad and sender will be added to users.<br>
But even if it is not planned to use, But even if it is not planned to be in use,
it is [required](https://github.com/zammad/zammad/issues/2352) for sending it is [required](https://github.com/zammad/zammad/issues/2352) for sending
email notifications using triggers. email notifications using triggers.
@@ -158,19 +158,20 @@ Basic setup and use
# Update # Update
While [Watchtower](https://github.com/DoTheEvo/selfhosted-apps-docker/tree/master/watchtower) While [Watchtower](https://github.com/DoTheEvo/selfhosted-apps-docker/tree/master/watchtower)
might work for containers fine. might work for containers of the stack,
I might prefer manual update, where it's basicly delete all, git clone new, and restore backups. might be prefered to just do backup and restore in a new git clone.
# Backup and restore # Backup and restore
#### Backup #### Backup
Out of the box a container doing daily backups is running. Out of the box a container doing daily backups is running.
Creating two files - backup of the database, and backup of the zammad files.
By default these are saved to a docker volume, but in override it has been changed By default these are saved to a docker volume, but in override it has been changed
to bind mount in the zammad directory. to a bind mount in the zammad-docker-compose directory.
So using [borg](https://github.com/DoTheEvo/selfhosted-apps-docker/tree/master/borg_backup) So using [borg](https://github.com/DoTheEvo/selfhosted-apps-docker/tree/master/borg_backup)
that makes daily snapshot of the entire directory will keep backups safe.<br> that makes daily snapshot of the entire \~/docker directory will keep backups safe.<br>
#### Restore #### Restore
@@ -178,43 +179,45 @@ that makes daily snapshot of the entire directory will keep backups safe.<br>
* shutdown the stack and remove all named volumes * shutdown the stack and remove all named volumes
`docker-compose down -v` `docker-compose down -v`
Warning, by default the backups are in one of these volumes Warning, by default the backups are in one of these volumes
be sure you cope them somewhere else before using `-v` be sure you copy them somewhere else before using `-v`
* delete entire zammad directory containing the compose file and shit * delete entire `zammad-docker-compose` directory containing the compose file and shit
* git clone the repo for new installation * git clone the repo for new installation
* start it up, * start it up,
`docker-compose up -d` `docker-compose up -d` and wait few minutes till everything finishes,<br>
wait few minutes till everything finishes, ctop, select nginx container, arrow left shows the log,<br>
ctop, select nginx container, arrow left shows the log, should be at - "starting nginx..."
should be at - 'starting nginx...'
* stop it all - `docker-compose down` * stop it all - `docker-compose down`
* extract the database backup from `20210515183647_zammad_db.psql.gz`, * extract the database backup<br>
`gzip -dk 20210605053326_zammad_db.psql.gz` `gzip -dk 20210605053326_zammad_db.psql.gz`<br>
rename it to something shorter like backup_db.psql rename it to something shorter like backup_db.psql<br>
place it in to `/var/lib/docker/volumes/zammad-docker-compose_zammad-postgresql-data/_data/` place it in to `/var/lib/docker/volumes/zammad-docker-compose_zammad-postgresql-data/_data/`<br>
I use nnn file manager as root.
* start zammad-postgresql container * start zammad-postgresql container
`docker-compose up -d zammad-postgresql` `docker-compose up -d zammad-postgresql`
* exec in to it `docker exec -it zammad-docker-compose_zammad-postgresql_1 bash` * exec in to it `docker exec -it zammad-docker-compose_zammad-postgresql_1 bash`<br>
* test you can connect to the database `psql -U zammad` test you can connect to the database `psql -U zammad`<br>
quit `\q` quit `\q`<br>
* back in bash, drop the existing database `dropdb zammad_production -U zammad` back in bash, drop the existing database `dropdb zammad_production -U zammad`<br>
* create new empty database `createdb zammad_production -U zammad` create a new empty database `createdb zammad_production -U zammad`<br>
* restore data from backup in to it restore data from backup in to it<br>
`psql zammad_production < /var/lib/postgresql/data/backup_db.psql -U zammad` `psql zammad_production < /var/lib/postgresql/data/backup_db.psql -U zammad`<br>
if you get some errors about already existing, you forgot to drop the database if you get some errors about already existing, you forgot to drop the database
* exit and down the container * exit and down the container
`docker-compose down` `docker-compose down`
* on docker host navigate to `/var/lib/docker/volumes/zammad-docker-compose_zammad-data/_data/` * on docker host navigate to `/var/lib/docker/volumes/zammad-docker-compose_zammad-data/_data/`
and delete everything there and delete everything there
* extract 20210515183647_zammad_files.tar somewhere * extract zammad data somewhere<br>
`tar -xvpf 20210605053326_zammad_files.tar.gz` `tar -xvpf 20210605053326_zammad_files.tar.gz`<br>
copy content of opt/zammad/ containing - app, bin, config,... copy content of opt/zammad/ containing directories - app, bin, config,...<br>
in to /var/lib/... where you previously deleted this stuff in to /var/lib/... where you previously deleted this stuff<br>
* start everything again, I use nnn file manager as root.
* start everything<br>
`docker-compose up -d`
* exec to rake container and run `rake searchindex:rebuild` to fix searching * exec to rake container and run `rake searchindex:rebuild` to fix searching
in case something is not working righ, check nginx logs, In case something is not working right, check nginx logs.
depending on how you copied the stuff, there could be ownership issue Depending on how you copied the stuff, there could be ownership issue
so in nginx check /opt/zammad and its content with `ls -al` so in nginx check /opt/zammad and its content with `ls -al`,
if its owned by zammad user. if its owned by zammad user.
if its root use `chown -R zammad:zammad /opt/zammad` if its root use `chown -R zammad:zammad /opt/zammad`