Help with server migration

I could use a hand migrating my instance of Zammad to a new server.

The original instance was built from source.
Zammad-Version: 4.0
Database: postgresql
Elasticsearch version: 7.12.1

I’ve prepared the new server with a working instance of Zammad using instructions from:

Zammad-Version: 4.0
Database: postgresql
Elasticsearch version: 7.12.1

I’m referencing the backup/restore docs at:
https://docs.zammad.org/en/latest/appendix/backup-and-restore.html

On the original machine, I ran:

cp /opt/zammad/contrib/backup/config.dist /opt/zammad/contrib/backup/config

and created the directory:

/var/tmp/zammad_backup

Then I changed directories to:

cd /opt/zammad/contrib/backup

and ran:

./zammad_backup.sh

This created 2 new files in /var/tmp/zammad_backup:

20210514171457_zammad_files.tar.gz
latest_zammad_files.tar.gz

On the new machine, I ran:

cp /opt/zammad/contrib/backup/config.dist /opt/zammad/contrib/backup/config

and created the directory:

/var/tmp/zammad_backup

Copied backup from old server to new server:

scp /var/tmp/zammad_backup/ root@newserver:/var/tmp/zammad_backup

Changed directory to:

cd /opt/zammad/contrib/backup

ran the restore script:

./zammad_restore.sh

At the prompt:

# Zammad restored started - Fri 14 May 2021 05:45:33 PM UTC!

The restore will delete your current config and database!
Be sure to have a backup available!

Enter 'yes' if you want to proceed!
Restore?:

I type yes

Enter file date to restore:
20210514171457
latest
File date:

I type:

20210514171457
Enter db date to restore:

DB date:

I type:

20210514171457

and I get an error:

File /var/tmp/zammad_backup/20210514171457_zammad_db.psql.gz does not exist!
Restore aborted!

As far as I can tell, the backup script isn’t creating a dump of the psql and I’m not sure how to proceed.
Thanks in advance for any help.

My database.yml from the Original machine looks like this:


# this is a database config sample for zammad ready to use with a postgresql db
# copy or symlink this file to config/database.yml to use it

default: &default
  # For details on connection pooling, see Rails configuration guide
  # http://guides.rubyonrails.org/configuring.html#database-pooling
  pool: 50
  timeout: 5000
  encoding: utf8

  ##### postgresql config #####

  adapter: postgresql
  # username: zammad
  # password:

  # If the database server is not on localhost, you can set hostname and port:
  # host:
  # port:

  #### mysql config #####

  # adapter: mysql2
  # username: zammad
  # password: <Password>

  # If the database server is not on localhost, you can set hostname and port:
  # host:
  # port:

production:
  <<: *default
  database: zammad_production

development:
  <<: *default
  database: zammad_development

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  <<: *default
  database: zammad_test

and the new database.yml looks like:

production:
  adapter: postgresql
  database: zammad
  pool: 50
  timeout: 5000
  encoding: utf8
  username: zammad
  password: some_crazy_password

if you are copying a directory, you must use scp -r instead, like this:

HTH,
Martin

@rsysadmin Thanks for the reply!
I’m not sure that using -r would help in this instance.
My original backup directory only has 2 files:

20210514171457_zammad_files.tar.gz
latest_zammad_files.tar.gz

and the restore script is looking for:

_zammad_db.psql.gz

You could try doing a manual dump to see why it’s not working.

Just have a look at the following files:

/opt/zammad/contrib/backup/zammad_backup.sh
/opt/zammad/contrib/backup/functions

In your case the dump should be done via:

su -c "pg_dump --no-privileges --no-owner -c ${DB_NAME} | \
  gzip > /tmp/${TIMESTAMP}_zammad_db.psql.gz" postgres

The variables are set via:

DB_NAME="$(grep 'database:' < ${ZAMMAD_DIR}/config/database.yml | sed -e 's/.*database:\(\| \) //g')"
TIMESTAMP="$(date +'%Y%m%d%H%M%S')"

Since you already know your DB_NAME and TIMESTAMP is just a simple timestamp you could simply do this f. e.:

su -c "pg_dump --no-privileges --no-owner -c zammad | \
  gzip > /tmp/20210517145701_zammad_db.psql.gz" postgres

There should be at least some response to why it’s not working.

cheers

1 Like

Hi @dust_bro

the -r switch instructs scp to copy a directory recursively, what is what you want to achieve here…

From man scp:

 -r      Recursively copy entire directories.  Note that scp follows symbolic links encountered in the tree
         traversal.

In other words: nothing will be copied and scp yields an error:

$ scp logs/ user@remoteserver:
user@remoteserver’s password:
logs: not a regular file

Best,
Martin

1 Like

This got me one step closer. I was able to backup and restore, but now I’m getting an error when I access zammad:

<% else %>
<%= @exception.message %>
<% if @exception.backtrace %>

<% @exception.backtrace.each {|row| %>
  <%= row %>
<% } %>
<% end %> <% end %>

Gonna check out the logs and see if I can get any details.

After a quick check, I see:

Can't reconnect to database #<ActiveRecord::NoDatabaseError: FATAL:  database "zammad_production" does not exist

Database names are probably different.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.