[solved] General update question

  • Used Zammad version: 2.3.x
  • Used Zammad installation source: Install with Docker-Compose
  • Operating system: Debian 9

Hello guys,

so I want to update my old Zammad installation to the newest version 2.9.x and after the update I want to restore it on a new installed Zammad Server (install on debian via deb)
Is it possible to update directly from 2.3 to 2.9 ?
Or do I have to make intermediate updates in the versions?
Like from 2.3 -> 2.4 -> 2.5 -> 2.6 -> …

Best regards
Tao

Heya,

a direct upgrade should be no problem, Zammad will update your database tables based on what’s missing and do conversion magic. The upgrade process might take longer than usual depending on the data your instance holds.

Please ensure to have a backup/snapshot - just in case.

1 Like

Thanks for the answer :v:
I will try it tommorrow :slight_smile:

1 Like

####Update 20.03.2019 11:52
The Update worked perfect and easy.

docker-compose stop
git pull
docker-compose pull
docker-compose up

Next step is to export the database to the new server.
I’ll report the status later.

1 Like

Should I stop the Zammad services before I restore the data on the new server ?
./zammad_restore.sh

It doesn’t hurt to do that. It’s not needed. It would be way more important during a backup :slight_smile:

1 Like

What about the backups Zammad makes automatically ?
They are made while the system is running.
or am I wrong ?

That’s correct. The docker-compose create a backup every 24 hours during runtime.
Especially if you want to migrate from A to B it makes sense to stop Zammad-Services if possible (or ensure no communication is done any more). Reason for this is, that you want to ensure no data is changed in your “old” Zammad after restoring.

After I started the “restore.sh” script I got the following messages.

ERROR: Relation "activity_streams" already exists
OLD TABLE
ERROR: Relation "activity_streams_id_seq" already exists
OLD TABLE

← there are even more such errors

2384
(1 line)

ERROR: duplicate key value violates unique constraint "ar_internal_metadata_pkey
DETAIL: Key "(key)=(environment)" already exists.
CONTEXT: COPY ar_internal_metadata, line 1
COPY 0
 setval

← there are even more such errors

ERROR: Relation "index_karma_users_on_user_id" already exists
← there are even more such errors

This is my console history:

41  cd opt/zammad/contrib/backup/
   42  mv config.dist config
   43  ls
   44  ./zammad_backup.sh (made a backup from the new server)
   45  ./zammad_restore.sh (restore of the old backup)

When i want to access the site, only a 502 bad gateway appears.

Side info: I didn’t stopped the zammad services on the new server.
Both Zammad Version are 2.9.x and the backup which i want to restore is from today.

What did I do wrong?

Maybe you’ll want to drop the existing database: zammad run rake db:drop
Please note that you might need the following documentation page to run the above, for security reasons (aka. anyone finding this command having to read without destroying stuff blind :wink: ): https://docs.zammad.org/en/latest/appendix-configure-env-vars.html

What is your destination OS? A debian as well?

1 Like

What is your destination OS? A debian as well?

Yes Sir.

I can’t get any smarter from the link.
I have executed youre following instruction zammad run rake db:drop but it didnt worked so I ran the following order:
zammad run rake db:drop DISABLE_DATABASE_ENVIRONMENT_CHECK=1 --trace
This is the message I get: (the language is german)

PG::ObjectInUse: FEHLER:  auf Datenbank »zammad« wird von anderen Benutzern zugegriffen
DETAIL:  10 andere Sitzungen verwenden die Datenbank.
: DROP DATABASE IF EXISTS "zammad"
Couldn't drop database 'zammad'
rake aborted!
ActiveRecord::StatementInvalid: PG::ObjectInUse: FEHLER:  auf Datenbank »zammad« wird von anderen Benutzern zugegriffen
DETAIL:  10 andere Sitzungen verwenden die Datenbank.
: DROP DATABASE IF EXISTS "zammad"
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `a                              sync_exec'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `b                              lock (2 levels) in execute'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6.2/lib/active_support/dependencies/interlock.rb:46:in `block in permit_concurrent_                              loads'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6.2/lib/active_support/concurrency/share_lock.rb:185:in `yield_shares'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6.2/lib/active_support/dependencies/interlock.rb:45:in `permit_concurrent_loads'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:72:in `b                              lock in execute'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6.2/lib/active_record/connection_adapters/abstract_adapter.rb:613:in `block (2 level                              s) in log'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6.2/lib/active_record/connection_adapters/abstract_adapter.rb:612:in `block in log'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6.2/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6.2/lib/active_record/connection_adapters/abstract_adapter.rb:604:in `log'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:71:in `e                              xecute'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6.2/lib/active_record/connection_adapters/postgresql/schema_statements.rb:54:in `dro                              p_database'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6.2/lib/active_record/tasks/postgresql_database_tasks.rb:32:in `drop'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6.2/lib/active_record/tasks/database_tasks.rb:144:in `drop'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6.2/lib/active_record/tasks/database_tasks.rb:160:in `block in drop_current'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6.2/lib/active_record/tasks/database_tasks.rb:305:in `block in each_current_configur                              ation'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6.2/lib/active_record/tasks/database_tasks.rb:302:in `each'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6.2/lib/active_record/tasks/database_tasks.rb:302:in `each_current_configuration'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6.2/lib/active_record/tasks/database_tasks.rb:159:in `drop_current'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6.2/lib/active_record/railties/databases.rake:42:in `block (2 levels) in <top (requi                              red)>'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6.2/lib/active_record/railties/databases.rake:38:in `block (2 levels) in <top (requi                              red)>'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/cli/exec.rb:74:in `load'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/cli/exec.rb:74:in `kernel_load'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/cli/exec.rb:27:in `run'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/cli.rb:360:in `exec'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/vendor/thor/lib/thor.rb:369:in `dispatch'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/cli.rb:20:in `dispatch'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/vendor/thor/lib/thor/base.rb:444:in `start'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/cli.rb:10:in `start'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/exe/bundle:30:in `block in <top (required)>'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/friendly_errors.rb:121:in `with_friendly_errors'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/exe/bundle:22:in `<top (required)>'
/opt/zammad/bin/bundle:3:in `load'
/opt/zammad/bin/bundle:3:in `<main>'

Caused by:
PG::ObjectInUse: FEHLER:  auf Datenbank »zammad« wird von anderen Benutzern zugegriffen
DETAIL:  10 andere Sitzungen verwenden die Datenbank.
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `a                              sync_exec'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `b                              lock (2 levels) in execute'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6.2/lib/active_support/dependencies/interlock.rb:46:in `block in permit_concurrent_                              loads'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6.2/lib/active_support/concurrency/share_lock.rb:185:in `yield_shares'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6.2/lib/active_support/dependencies/interlock.rb:45:in `permit_concurrent_loads'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:72:in `b                              lock in execute'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6.2/lib/active_record/connection_adapters/abstract_adapter.rb:613:in `block (2 level                              s) in log'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6.2/lib/active_record/connection_adapters/abstract_adapter.rb:612:in `block in log'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6.2/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6.2/lib/active_record/connection_adapters/abstract_adapter.rb:604:in `log'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:71:in `e                              xecute'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6.2/lib/active_record/connection_adapters/postgresql/schema_statements.rb:54:in `dro                              p_database'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6.2/lib/active_record/tasks/postgresql_database_tasks.rb:32:in `drop'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6.2/lib/active_record/tasks/database_tasks.rb:144:in `drop'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6.2/lib/active_record/tasks/database_tasks.rb:160:in `block in drop_current'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6.2/lib/active_record/tasks/database_tasks.rb:305:in `block in each_current_configur                              ation'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6.2/lib/active_record/tasks/database_tasks.rb:302:in `each'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6.2/lib/active_record/tasks/database_tasks.rb:302:in `each_current_configuration'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6.2/lib/active_record/tasks/database_tasks.rb:159:in `drop_current'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6.2/lib/active_record/railties/databases.rake:42:in `block (2 levels) in <top (requi                              red)>'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6.2/lib/active_record/railties/databases.rake:38:in `block (2 levels) in <top (requi                              red)>'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/cli/exec.rb:74:in `load'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/cli/exec.rb:74:in `kernel_load'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/cli/exec.rb:27:in `run'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/cli.rb:360:in `exec'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/vendor/thor/lib/thor.rb:369:in `dispatch'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/cli.rb:20:in `dispatch'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/vendor/thor/lib/thor/base.rb:444:in `start'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/cli.rb:10:in `start'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/exe/bundle:30:in `block in <top (required)>'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/friendly_errors.rb:121:in `with_friendly_errors'
/opt/zammad/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/exe/bundle:22:in `<top (required)>'
/opt/zammad/bin/bundle:3:in `load'
/opt/zammad/bin/bundle:3:in `<main>'
Tasks: TOP => db:drop:_unsafe
(See full trace by running task with --trace)

The funny thing is, I haven’t set up the new system yet.
So actually no users can be logged in.
It has only been reinstalled.

Your error message contains your answer:

“ActiveRecord::StatementInvalid: PG::ObjectInUse: FEHLER: auf Datenbank »zammad« wird von anderen Benutzern zugegriffen
DETAIL: 10 andere Sitzungen verwenden die Datenbank.”

This means, if you have installed Zammad, you need to stop it before. If necessary restart postgresql as well. Ensure Zammad is not running.

Can you be more specific? If necessary restart postgresql as well.
Do I have to restart afterwards or before the restoring ?

Stop the Zammad service before restoation and check if any further Zammad-Services are running.
If you still receive the “still in use” error during restoration, restart the postgresql service to ensure all connections are closed.

This should solve the problem.

So I stopped the zammad service.
And everything went well. During recovery, the following error message occurred:

psql: FATAL: database “zammad_production” does not exist

Do I have to create the database manually ? I thought the zammad_restore.sh will do it automatically.


grafik
grafik

As far as I can tell from the source, the restore script just pipes the dump into psql:

    echo "# Restoring PostgrSQL DB"
    zcat ${BACKUP_DIR}/${RESTORE_DB_DATE}_zammad_db.${DB_FILE_EXT}.gz | su -c "psql -d ${DB_NAME}" postgres

As this is a pg_dump backup, it only contains the database contents (tables etc.) and no CREATE DATABASE command, and psql of course expects the database to already exists because the script instructs it to connect to it.

I’m not really sure how the restore is exactly supposed to work - it claims “The restore will delete your current config and database!”, but I don’t see any instructions to delete the old database…? It’s also apparently in dire need of a lot of quotes (in shell script, variables always need to be quoted) and some set -eu instructions so that it actually handles failures :confused:

Try to manually create the database with rake db:create, and then try the restore script again.

2 Likes

Martin is right.
Normally it not dump the database itself. This might be because the database on the earlier system had another name. It’s possible that you need to create it manually.

To be honest, I’m kind of out of there, because I don’t know if there are differences in the docker part.

Thanks for the reply. This doesnt work for me either.
This is the following error message:

PG::InsufficientPrivilege: ERROR: no authorization to create database

I also tried it with > su - postgres but its telling me to do it with the zammad user but the error message is telling me that I dont have the rights to do it.

I also checked the list of role:

So I tried it with the user zammad.
Without sudo:

With sudo:
(They want a password and its not the root login password…so which password can it be ?

I changed the privilege of the user “zammad” to Superuser and this worked perfectly.

postgres=# ALTER USER zammad WITH SUPERUSER;

Voilà zammad run rake db:create worked
grafik

So the restoring has shown no error or something like this.
Just CREATE INDEX and ALTER TABEL and stuff like this.
But the site is still not available: (But you can see the zammad icon)

Could there be a problem with the old server?
Because it is still online and also there in the config the FQDN has entered, which is now also taken over by the new server.

I also restarted all 3 services (nginx, zammad and postgresql) and the whole server.
And the /etc/nginx/sites-enabled/zammad.conf has the correct ip adress.