Kubrik OSSUPPORTSOPORTE All productsTodos los productos
Technical manualManual técnico › Operation › Protecting the data › Backups and restoreOperación › Cuidar los datos › Copias de seguridad y restauración

Backups and restore

Copias de seguridad y restauración

Kubrik OS does not back itself up. Three things have to be copied, and the three have to be restored together: the database, the file store and the configuration with its secret keys.

Kubrik OS no hace copias por su cuenta. Hay tres cosas que copiar, y las tres se restauran juntas: la base de datos, el almacén de archivos y la configuración con sus claves secretas.

👤 Who: System administrator📍 Where: Server console
👤 Quién: Administrador de sistemas📍 Dónde: Consola del servidor

What must be backed up

Qué hay que copiar

WhatWhere it isWhat you lose without it
The databaseThe postgres service, volume pgdata-<edition>.Everything: organisations, users, products, documents, accounting.
The file storeThe bucket named in MINIO_S3_BUCKET. With the Enterprise file, the volume minio-enterprise.Every uploaded file: product images, attached documents. The database keeps only the reference to each file.
The configurationThe Compose file you edited, .env and, if you use it, assets/config.json.The settings of the installation and, above all, its secret keys.
QuéDónde estáQué perdés sin eso
La base de datosEl servicio postgres, volumen pgdata-<edición>.Todo: organizaciones, usuarios, productos, documentos, contabilidad.
El almacén de archivosEl bucket que figura en MINIO_S3_BUCKET. Con el archivo de Enterprise, el volumen minio-enterprise.Todos los archivos subidos: imágenes de productos, documentos adjuntos. La base guarda solo la referencia a cada archivo.
La configuraciónEl archivo Compose que editaste, .env y, si lo usás, assets/config.json.Los ajustes de la instalación y, sobre todo, sus claves secretas.
⛔
A database copy without its keys is incomplete. KSERP_MASTER_KEY_V1, KUBRIK_WORKFLOW_SECRET_KEY and PMS_SECURITY_TOTP_ENCRYPTION_KEY encrypt data that lives inside the database. Restored with different keys, the database opens but the stored access data of external services cannot be read and no user can pass the two-step verification. Keep the keys in a second safe place, apart from the database copies.Una copia de la base sin sus claves está incompleta. KSERP_MASTER_KEY_V1, KUBRIK_WORKFLOW_SECRET_KEY y PMS_SECURITY_TOTP_ENCRYPTION_KEY cifran datos que viven dentro de la base. Restaurada con otras claves, la base abre pero los datos de acceso guardados de servicios externos no se pueden leer y ningún usuario pasa la verificación en dos pasos. Guardá las claves en un segundo lugar seguro, aparte de las copias de la base.

The cache needs no backup, and the location database can be downloaded again.

La caché no necesita copia, y la base de ubicación se puede bajar de nuevo.

Back up the database

Copiar la base de datos

Use the standard PostgreSQL tool, which is inside the postgres container. It can run while the system is in use.

Usá la herramienta estándar de PostgreSQL, que está dentro del contenedor postgres. Se puede correr con el sistema en uso.

  1. Run the copy. docker compose -f docker-compose.<edition>.yml exec -T postgres pg_dump -U ks_erp_java -Fc ks_erp_java > kubrik-os.dump
  2. Check the file. It must not be empty, and its size should resemble that of the previous copy.
  3. Take it off the server. A copy that lives only on the same disk as the database does not protect you.
  1. Corré la copia. docker compose -f docker-compose.<edición>.yml exec -T postgres pg_dump -U ks_erp_java -Fc ks_erp_java > kubrik-os.dump
  2. Revisá el archivo. No tiene que estar vacío, y su tamaño debería parecerse al de la copia anterior.
  3. Sacalo del servidor. Una copia que vive solo en el mismo disco que la base no te protege.

ks_erp_java is the name of the database and of its owner in the Compose files. If you changed them, use yours.

ks_erp_java es el nombre de la base y el de su dueño en los archivos Compose. Si los cambiaste, usá los tuyos.

Back up the file store

Copiar el almacén de archivos

Copy the whole bucket with the tool of your file store: the MinIO client for a MinIO server, or the versioning and replication of the bucket in Amazon S3. Do it right after the database copy, so that both reflect the same moment. A file store that is slightly newer than the database does no harm; an older one leaves records that point to files that are not there.

Copiá el bucket entero con la herramienta de tu almacén: el cliente de MinIO para un servidor MinIO, o el versionado y la replicación del bucket en Amazon S3. Hacelo enseguida después de la copia de la base, para que las dos reflejen el mismo momento. Un almacén un poco más nuevo que la base no hace daño; uno más viejo deja registros que apuntan a archivos que no están.

Restore

Restaurar

  1. Put the configuration back: the Compose file and .env with the original keys.
  2. Start only the database. docker compose -f docker-compose.<edition>.yml up -d postgres
  3. Load the copy into an empty database. docker compose -f docker-compose.<edition>.yml exec -T postgres pg_restore -U ks_erp_java -d ks_erp_java --clean --if-exists < kubrik-os.dump
  4. Put the files back in the bucket.
  5. Start the rest. docker compose -f docker-compose.<edition>.yml up -d. Use images of the same version as the copy, or a newer one: at start-up the application brings the database up to its own version.
  6. Check with curl http://localhost:8222/actuator/health, sign in and open a record with an image.
  1. Volvé a poner la configuración: el archivo Compose y .env con las claves originales.
  2. Levantá solo la base de datos. docker compose -f docker-compose.<edición>.yml up -d postgres
  3. Cargá la copia en una base vacía. docker compose -f docker-compose.<edición>.yml exec -T postgres pg_restore -U ks_erp_java -d ks_erp_java --clean --if-exists < kubrik-os.dump
  4. Volvé a poner los archivos en el bucket.
  5. Levantá el resto. docker compose -f docker-compose.<edición>.yml up -d. Usá imágenes de la misma versión que la copia, o de una más nueva: al arrancar, la aplicación lleva la base a su propia versión.
  6. Revisá con curl http://localhost:8222/actuator/health, ingresá y abrí un registro con imagen.
⚠️
Never start an older version of the application on a newer database. The application refuses to start when the database has changes it does not know. To go back to an earlier version, restore the copy you made before upgrading.Nunca arranques una versión anterior de la aplicación sobre una base más nueva. La aplicación se niega a arrancar cuando la base tiene cambios que no conoce. Para volver a una versión anterior, restaurá la copia que hiciste antes de actualizar.
💡
Rehearse the restore. Load a copy on another machine from time to time. A backup that was never restored is only a hope.Ensayá la restauración. Cada tanto, cargá una copia en otra máquina. Una copia que nunca se restauró es solo una esperanza.

Common issues

Problemas habituales

After a restore, sign-in works but nobody passes the two-step verification
The installation runs with a different PMS_SECURITY_TOTP_ENCRYPTION_KEY than the one of the copy. Put the original key back.
After a restore, an integration reports that its access data is invalid
KSERP_MASTER_KEY_V1 or KUBRIK_WORKFLOW_SECRET_KEY are not the original ones. Put them back; if they are lost, the access data has to be loaded again in each organisation.
After a restore, products show no image
The file store was not restored, or it is older than the database, or MINIO_S3_BUCKET points to another bucket.
pg_restore reports errors about roles
The copy names database users that do not exist in the new server. Start the application once on the empty database so that it creates them, then restore.
Después de restaurar, el ingreso funciona pero nadie pasa la verificación en dos pasos
La instalación corre con otra PMS_SECURITY_TOTP_ENCRYPTION_KEY que la de la copia. Volvé a poner la clave original.
Después de restaurar, una integración informa que sus datos de acceso no son válidos
KSERP_MASTER_KEY_V1 o KUBRIK_WORKFLOW_SECRET_KEY no son las originales. Volvé a ponerlas; si se perdieron, hay que cargar de nuevo los datos de acceso en cada organización.
Después de restaurar, los productos no muestran imagen
El almacén de archivos no se restauró, o es más viejo que la base, o MINIO_S3_BUCKET apunta a otro bucket.
pg_restore informa errores sobre roles
La copia nombra usuarios de base de datos que no existen en el servidor nuevo. Arrancá la aplicación una vez sobre la base vacía para que los cree, y después restaurá.

RelatedRelacionado