Zammad problems with restore

Hi anybody can tell me if has the same proble when make a backup and execute the restore?

root@hds:~# ls -lla /var/tmp/zammad_backup/
total 800516
drwxr-xr-x 2 zammad zammad      4096 nov 16 10:35 .
drwxrwxrwt 9 root   root        4096 nov 16 10:01 ..
-rw-rw-r-- 1 zammad zammad  21045426 nov 15 22:38 20211115223828_zammad_db.psql
-rw-r--r-- 1 zammad zammad   5263967 nov 16 10:35 20211115223828_zammad_db.psql.gz
-rw-rw-r-- 1 zammad zammad 129064511 nov 15 22:38 20211115223828_zammad_files.tar.gz
lrwxrwxrwx 1 zammad zammad        55 nov 15 22:38 latest_zammad_db.psql.gz -> /var/tmp/zammad_backup/20211115223828_zammad_db.psql.gz
lrwxrwxrwx 1 zammad zammad        57 nov 15 22:38 latest_zammad_files.tar.gz -> /var/tmp/zammad_backup/20211115223828_zammad_files.tar.gz
-rw-r--r-- 1 zammad zammad 664333092 nov  6 15:31 OneDrive_1_27-10-2021.zip
root@hds:~# su - zammad 
zammad@hds:~$ cd /opt/zammad/contrib/
apache2/                   mac_developer_scripts.app/ packager.io/
backup/                    nginx/                     
zammad@hds:~$ cd /opt/zammad/contrib/backup/
zammad@hds:/opt/zammad/contrib/backup$ ls
config	config.dist  functions	zammad_backup.sh  zammad_restore.sh

Before of this i make a backup with the tool of zammad, how you can see i have this files, then i execute the restore script

zammad@hds:/opt/zammad/contrib/backup$ ./zammad_restore.sh

# Zammad restored started - mar 16 nov 2021 10:42:38 -05!

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

Enter 'yes' if you want to proceed!
Restore?: yes
Enter file date to restore: 
20211115223828
File date: 20211115223828
Enter db date to restore: 
20211115223828
DB date: 20211115223828
# Stopping Zammad
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to stop 'zammad.service'.
**Authenticating as: Ubuntu (adminsoc)**
Password: 
==== AUTHENTICATION COMPLETE ===
# Checking requirements
# ... Dropping current database zammad
Dropped database 'zammad'
# ... Creating database zammad for owner zammad
Password: 
su: Authentication failure
# Restoring PostgreSQL DB
psql: error: FATAL:  database "zammad" does not exist
# Restoring Files
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/design_rationale.rb: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/.autotest: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/Manifest.txt: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/minitest.rb: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/minitest/autorun.rb: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/minitest/assertions.rb: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/minitest/parallel.rb: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/minitest/unit.rb: Cannot open: Permission denied
....
....
test.rb: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/minitest/pride_plugin.rb: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/hoe/minitest.rb: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/Rakefile: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/History.rdoc: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/README.rdoc: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/test/minitest/test_minitest_mock.rb: Cannot open: Permission denied
...
...
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/test/minitest/test_minitest_test.rb: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/test/minitest/metametameta.rb: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/test/minitest/test_minitest_benchmark.rb: Cannot open: Permission denied
tar: Exiting with failure status due to previous errors
# Ensuring correct file rights ...
# Clearing Cache ...
# Starting Zammad
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to start 'zammad.service'.
Authenticating as: Ubuntu (adminsoc)
Password: 
==== AUTHENTICATION COMPLETE ===

# Zammad restored successfully - mar 16 nov 2021 10:44:17 -05!

zammad@hds:/opt/zammad/contrib/backup$ psql 
psql: error: FATAL:  database "zammad" does not exist
zammad@hds:/opt/zammad/contrib/backup$ exit
logout
root@hds:~# su - postgres 
postgres@hds:~$ psql 
psql (13.5 (Ubuntu 13.5-0ubuntu0.21.10.1))
Type "help" for help.

postgres=# \l
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
-----------+----------+----------+-------------+-------------+-----------------------
 postgres  | postgres | UTF8     | es_ES.UTF-8 | es_ES.UTF-8 | 
 template0 | postgres | UTF8     | es_ES.UTF-8 | es_ES.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | es_ES.UTF-8 | es_ES.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
(3 rows)

postgres=#

First i dont know why appear “Authenticating as: Ubuntu (adminsoc)” because the hostname is hds also not is a session on this server, The same is with the message “su: Authentication failure” because i put th root password, then i see the databases but only delete zammad database and not restore.

The only one way that i can restore is uncompress the backup.tar.gz and with command postgresql i restore the psql file and i can restore all my information. Anybody can the same problem?

Greetings, guys!

I happen to have the same problem on Ubuntu Server LTS 20.04 with Zammad 5.0x installed as a package.

After the last zammad update (from version 5.0x to 5.0y), the backup script, that had always worked before, didn’t work anymore. Before the update, I was able to run the script with sudo, after the update, I encountered exactly the same error as @klausneil when executing it. I was able to bypass the problem by executing the backup script by the zammad user. Doing so, the backup completed without any errors.

Now, when I try to restore the backup files, I get exactly the same error as klaus, no matter if I use sudo or the zammad user.

Any constructive suggestions or hints to solve this are very welcome. And I am happy to buy you a beer :wink:

I have a similar problem. It is recommended to use the zammad-user for backups, but restoring doesn’t work with any user. It looks a bit like this issue with postgresql (which was closed):

It seems that the zammad user doesn’t have the rights to recreate the database zammad.
And the zammad user cannot write files to the system, in your case:

opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/

@claas Yes, I can confirm that…

# Zammad restored started - Sa 11. Dez 22:04:00 CET 2021!

# Stopping Zammad
# Checking requirements
# ... Dropping current database zammad
Dropped database 'zammad'
# ... Creating database zammad for owner zammad
Passwort: 
su: Legitimierungsfehler
# Restoring PostgreSQL DB
psql: error: FATAL:  database "zammad" does not exist
# Restoring Files
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/design_rationale.rb: Funktion open fehlgeschlagen: Keine Berechtigung
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/.autotest: Funktion open fehlgeschlagen: Keine Berechtigung
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/minitest/pride_plugin.rb: Funktion open fehlgeschlagen: Keine Berechtigung
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/minitest/unit.rb: Funktion open fehlgeschlagen: Keine Berechtigung
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/minitest/spec.rb: Funktion open fehlgeschlagen: Keine Berechtigung
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/minitest/expectations.rb: Funktion open fehlgeschlagen: Keine Berechtigung
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/minitest/parallel.rb: Funktion open fehlgeschlagen: Keine Berechtigung
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/minitest/assertions.rb: Funktion open fehlgeschlagen: Keine Berechtigung
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/minitest/hell.rb: Funktion open fehlgeschlagen: Keine Berechtigung
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/minitest/test.rb: Funktion open fehlgeschlagen: Keine Berechtigung
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/minitest/benchmark.rb: Funktion open fehlgeschlagen: Keine Berechtigung
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/minitest/pride.rb: Funktion open fehlgeschlagen: Keine Berechtigung
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/minitest/mock.rb: Funktion open fehlgeschlagen: Keine Berechtigung
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/minitest/autorun.rb: Funktion open fehlgeschlagen: Keine Berechtigung
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/hoe/minitest.rb: Funktion open fehlgeschlagen: Keine Berechtigung
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/minitest.rb: Funktion open fehlgeschlagen: Keine Berechtigung
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/Manifest.txt: Funktion open fehlgeschlagen: Keine Berechtigung
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/test/minitest/test_minitest_mock.rb: Funktion open fehlgeschlagen: Keine Berechtigung
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/test/minitest/test_minitest_benchmark.rb: Funktion open fehlgeschlagen: Keine Berechtigung
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/test/minitest/test_minitest_reporter.rb: Funktion open fehlgeschlagen: Keine Berechtigung
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/test/minitest/test_minitest_assertions.rb: Funktion open fehlgeschlagen: Keine Berechtigung
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/test/minitest/metametameta.rb: Funktion open fehlgeschlagen: Keine Berechtigung
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/test/minitest/test_minitest_spec.rb: Funktion open fehlgeschlagen: Keine Berechtigung
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/test/minitest/test_minitest_test.rb: Funktion open fehlgeschlagen: Keine Berechtigung
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/README.rdoc: Funktion open fehlgeschlagen: Keine Berechtigung
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/Rakefile: Funktion open fehlgeschlagen: Keine Berechtigung
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/History.rdoc: Funktion open fehlgeschlagen: Keine Berechtigung
tar: opt/zammad/contrib/backup/zammad_backup_plus.sh: Funktion open fehlgeschlagen: Keine Berechtigung
tar: Beende mit Fehlerstatus aufgrund vorheriger Fehler
# Ensuring correct file rights ...
# Clearing Cache ...
# Starting Zammad

# Zammad restored successfully - Sa 11. Dez 22:04:23 CET 2021!

Unfortunately, I have not been able to find a solution to this day. Is it possible, that the restore script is broken?

Hey @Aladdin I’ve got the same issue when I was trying to migrate my old Zammad-Server (4.0.8) to the newly installed version. As far as I can see there seem to be changes in the functions of the restore script.
I’m locking forward to some great ideas to get a workaround!

Hi @Aladdin when you finnish the wizard installation then you execute the script restore, here appear the error and the zammad database is delete, then you create a new database as zammad and give the privileges as say this link then you can import the database how say this other link i hope that this work fine for you.

Hi,

Had the same problem trying to restore on a fresh Ubuntu server with Zammad version 5.

This resolved my problem.

On Target server

BEFORE RUNNING ./zammad_restore.sh

Step 1:

chmod -R u+w /opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4

To avoid the following errors during restore

tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/hoe/minitest.rb: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/minitest/assertions.rb: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/minitest/autorun.rb: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/minitest/benchmark.rb: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/minitest/expectations.rb: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/minitest/hell.rb: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/minitest/mock.rb: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/minitest/parallel.rb: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/minitest/pride.rb: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/minitest/pride_plugin.rb: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/minitest/spec.rb: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/minitest/test.rb: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/minitest/unit.rb: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/lib/minitest.rb: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/test/minitest/metametameta.rb: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/test/minitest/test_minitest_assertions.rb: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/test/minitest/test_minitest_benchmark.rb: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/test/minitest/test_minitest_mock.rb: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/test/minitest/test_minitest_reporter.rb: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/test/minitest/test_minitest_spec.rb: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/test/minitest/test_minitest_test.rb: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/.autotest: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/History.rdoc: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/Manifest.txt: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/README.rdoc: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/Rakefile: Cannot open: Permission denied
tar: opt/zammad/vendor/bundle/ruby/2.7.0/gems/minitest-5.14.4/design_rationale.rb: Cannot open: Permission denied

Step 2:

Change postgres user password

sudo -i
passwd postgres

from zammad user launch restore script

When prompted for password

# ... Creating database zammad for owner zammad
Password:

Enter postgres user password

1 Like

Thank you @klausneil, I appreciate your solution, although Felix’s solution seems to be easier to execute.

Thank you @Felix, although the restore script finished with an error, so far everything seems to be working just fine here!

A slight warning on Felix’s approach:
The postgres user by default has no password and is a system user.
This should be fine and changing this may potentially be dangerous to your system.

Run the restore as root user instead of zammad.
Also, as a day more or less shouldn’t hurt any further after all that time, consider waiting for the stable fix of this issue instead: Zammad backups (database and filesystem) are world-readable by default · Issue #3893 · zammad/zammad · GitHub

Subscribe to that issue. I’ll update it when the time has come.

I’ll not follow this thread further.

@MrGeneration Thanks for the warning! I will follow your suggestion and wait for the stable fix…

Time has come: Postgresql Backup & Restore failing on default package installations · Issue #3865 · zammad/zammad · GitHub