juanluisbaptiste / docker-otrs

The unofficial Znuny/OTRS Ticketing System docker image
https://www.juanbaptiste.tech/category/otrs
GNU Lesser General Public License v3.0
173 stars 101 forks source link

restoring backup troubles #39

Closed perler closed 6 years ago

perler commented 6 years ago

I have trouble creating a docker container from a non-docker backup. I read the docs this way, that I need to create the backup on the old installation with the script from the docker image. I copied it over together with the functions and let it run. it throw some error about not finding stop_all_services but created a backup file:

otrs-2018-09-06_12_42-full.tar.gz

I copied it to the docker server and mounted the directory with the file in it:

docker-compose.yml:

- '/srv/docker/data/otrs/backup:/var/otrs/backups'

ls -lisa /srv/docker/data/otrs/backup:

11010050       4 drwxr-xr-x 3  500   48       4096 Sep  6 15:07 .
11010049       4 drwxr-xr-x 5 root root       4096 Sep  6 11:24 ..
11012442       4 drwxrwx--- 2 root root       4096 Sep  6 12:49 2018-09-06_12-42
11012446 2356324 -rwxr-xr-x 1 root root 2412871680 Sep  6 13:36 otrs-2018-09-06_12_42-full.tar.gz

as you can see, I also tried to extract it to no avail. also, when extracting, 12_42 turns into 12-42.

anyway, this is what the otrs-setup.env looks like:

OTRS_INSTALL=restore
OTRS_BACKUP_DATE="2018-09-06_12-42"
OTRS_DROP_DATABASE=yes

and this is the error message:

 Restoring OTRS backup: "2018-09-06_12-42" for host otrs-
[INFO] Found existing configuration directory, Ok.
[INFO] Updating configuration option DatabaseUser with value: otrs
[INFO] Updating configuration option DatabasePw with value: changeme
[INFO] Updating configuration option DatabaseHost with value: mariadb
[INFO] Updating configuration option DatabasePort with value: 3306
[ERROR] Backup file does not exist !!

I am quite sure it is something small, but I just can't put my finger on it..

juanluisbaptiste commented 6 years ago

I copied it over together with the functions and let it run. it throw some error about not finding stop_all_services but created a backup file:

No, the backup script comes with OTRS, the /otrs_backup.sh is just a wrapper around it to avoid setting parameters. You can use /opt/otrs/scripts/backup.pl directly to create a backup.

[ERROR] Backup file does not exist !!

Check that you actually can see the backup inside the container on /var/otrs/backups/. In the same way as with the backups, you could call /opt/otrs/scripts/restore.pl directly with the appropiate parameters.

perler commented 6 years ago

ok, but just to be clear: your script is creating a tar.gz file, OTRS's backup.pl creates a directory with files. what is your restoration script expecting: your file or the directory?

juanluisbaptiste commented 6 years ago

I support both, directory or tar.gz. Yesterday I added a note about this to the README file.

juanluisbaptiste commented 6 years ago

I will close this, reopen if you have issues.

hpeixoto commented 4 years ago

It is the first time i want to restore a backup and it is not working:

[INFO] Restoring OTRS backup: "2019-11-07_06-00" for host otrs-QhYxyygX
[INFO] Found existing configuration directory, Ok.
[INFO] Updating configuration option DatabaseUser with value: otrs
[INFO] Updating configuration option DatabasePw with value: **********
[INFO] Updating configuration option DatabaseHost with value: mariadb
[INFO] Updating configuration option DatabasePort with value: 3306
[INFO] Updating configuration option Database with value: otrs
[ERROR] Backup file does not exist !!

I have checked and if I run the container without restore it sees the files under /var/otrs/backups/

[root@8bd70c72dbc3 /]# cd /var/otrs/backups/
[root@8bd70c72dbc3 backups]# ls -l
total 69212
-rw-rw-r-- 1 otrs 1000 34546085 Nov  7 05:00 otrs-2019-11-07_06-00-fullbackup.tar.gz

My .env looks like this:

OTRS_INSTALL=restore
OTRS_BACKUP_DATE="2019-11-07_06-00"

Any ideas on how I can perform this? Thanks!

juanluisbaptiste commented 4 years ago

The error is very clear, the container is not seeing your backup file. Check your mount paths.

hpeixoto commented 4 years ago

I understand that... Although the error is clear, as you can see I have successfully mounted the backup folders. Folder /var/otr/backups content in container:

[root@8bd70c72dbc3 /]# cd /var/otrs/backups/ [root@8bd70c72dbc3 backups]# ls -l total 69212 -rw-rw-r-- 1 otrs 1000 34546085 Nov 7 05:00 otrs-2019-11-07_06-00-fullbackup.tar.gz

What i figured out is that with the unzipped folder everything works...not with the tar.gz file, unfortunately. But that is enough for me! I have successfully backed up and restored my otrs!

Thanks!

juanluisbaptiste commented 4 years ago

So there must be wrong something with your backup file, I just tested it and it works fine:


[INFO] Restoring OTRS backup: otrs-2019-10-30_17-34-fullbackup.tar.gz for host support.xxxxxx.com
otrs_1     | [INFO] Found empty /opt/otrs/Kernel/, copying default configuration to it...
otrs_1     | [INFO] Done.
otrs_1     | [INFO] Updating configuration option DatabaseUser with value: otrs
otrs_1     | [INFO] Updating configuration option DatabasePw with value: **********
otrs_1     | [INFO] Updating configuration option DatabaseHost with value: mariadb
otrs_1     | [INFO] Adding configuration option DatabasePort with value: 3306
otrs_1     | [INFO] Updating configuration option Database with value: otrs
otrs_1     | 2019-10-30_17-34/
otrs_1     | 2019-10-30_17-34/DatabaseBackup.sql.gz
otrs_1     | 2019-10-30_17-34/Config.tar.gz
otrs_1     | 2019-10-30_17-34/Application.tar.gz
otrs_1     | ERROR 1049 (42000) at line 1: Unknown database 'otrs'
otrs_1     | [INFO] Creating OTRS database...
otrs_1     | Restore /tmp/tmp.nBrjUYCgLN/2019-10-30_17-34/Config.tar.gz ...
otrs_1     | Restore /tmp/tmp.nBrjUYCgLN/2019-10-30_17-34/Application.tar.gz ...
otrs_1     | create MySQL
otrs_1     | Restore database into MySQL ...
otrs_1     | [WARNING] OTRS version of backup being restored: 6.0.20
otrs_1     | [WARNING] OTRS version of this container: 6.0.23
juanluisbaptiste commented 4 years ago
[INFO] Restoring OTRS backup: "**2019-11-07_06-00**" for host otrs-QhYxyygX
[INFO] Found existing configuration directory, Ok.
[INFO] Updating configuration option DatabaseUser with value: otrs
[INFO] Updating configuration option DatabasePw with value: **********
[INFO] Updating configuration option DatabaseHost with value: mariadb
[INFO] Updating configuration option DatabasePort with value: 3306
[INFO] Updating configuration option Database with value: otrs
[ERROR] Backup file does not exist !!

I have checked and if I run the container without restore it sees the files under /var/otrs/backups/

[root@8bd70c72dbc3 /]# cd /var/otrs/backups/
[root@8bd70c72dbc3 backups]# ls -l
total 69212
-rw-rw-r-- 1 otrs 1000 34546085 Nov  7 05:00 otrs-2019-11-07_06-00-fullbackup.tar.gz

My .env looks like this:

OTRS_INSTALL=restore
OTRS_BACKUP_DATE="2019-11-07_06-00"

Looking again at your message I see the issue. You are setting OTRS_BACKUPDATE to a directory but you are putting on /var/otrs/backups_ a tarball. Did you read the documentation ? it is clear on how to do a backup restore:

Restore

To restore an OTRS backup file (not necessarily created with this container) the following environment variables must be added:

OTRS_INSTALL=restore Will restore the backup specified by OTRS_BACKUP_DATE environment variable.
  • OTRS_BACKUP_DATE is the backup name to restore. It can have two values:
    • Uncompressed backup: A directory with its name in the same date_time format that the OTRS backup script uses, for example OTRS_BACKUP_DATE="2015-05-26_00-32" with the backup files inside. A backup file created with this image or with any OTRS installation will work (the backup script creates the directory with that name). This feature is useful when migrating from another OTRS install to this container.
      • Compressed backup file: A gzip tarball of the previously described directory with the backup files. These tarballs are created by this container when doing a backup.

Backups must be inside the /var/otrs/backups directory (host mounted by default in the docker-compose file).

Remember to remove the OTRS_INSTALL=restore from the docker-compose file environment variables afterwards.

So if you plan to do a restore of thew tarball file then OTRS_BACKUP_DATE has to point to that file, not to the directory inside it.