> Versão Markdown de https://yucca.app/pt/docs/guides/DB/migration/. Índice da documentação: [llms.txt](https://yucca.app/pt/llms.txt), texto completo em um arquivo: [llms-full.txt](https://yucca.app/pt/llms-full.txt). Qualquer página está disponível como Markdown: adicione `.md` à URL sem a barra final.

# Migração de Sqlite para Postgres

## Visão geral

Se você começou a usar o Yucca com Sqlite e, depois, os recursos necessários cresceram, é possível migrar os dados do banco Sqlite para o Postgres. A migração reversa não é suportada.

## Migração

1. Implante e prepare o [postgres](https://yucca.app/pt/docs/guides/DB/postgres.md) com antecedência.

2. Pare o servidor Yucca:

   ```sh
   sudo systemctl stop yucca

   ```

3. Execute o comando de migração informando o caminho do banco de origem e do banco de destino:

   ```sh
   /opt/yucca/yucca admin migrate

   ```

   A lista de todos os parâmetros pode ser vista na ajuda:

   ```sh
   /opt/yucca/yucca admin migrate --help
   Migrate state from SQLite to PostgreSQL

   Usage:
   yucca admin migrate [flags]

   Flags:
       --config string                         Path to configuration file (default "/opt/yucca/yucca.toml")
       --data-dir string                       The data directory used to store state and other persistent data (default "data")
       --database-busy-timeout int             Timeout in seconds for waiting for an SQLite table to become unlocked (default 500)
       --database-ca-cert-path string          The path to the CA certificate to use (default "/etc/ssl/certs")
       --database-cache-mode string            Shared cache setting used for connecting to the database (private, shared) (default "shared")
       --database-client-cert-path string      The path to the client cert
       --database-client-key-path string       The path to the client key
       --database-conn-max-lifetime duration   Sets the maximum amount of time a connection may be reused (default 0s)
       --database-host string                  Database host (not applicable for sqlite3) (default "127.0.0.1:5432")
       --database-max-idle-conn int            The maximum number of connections in the idle connection pool (default 2)
       --database-max-open-conn int            The maximum number of open connections to the database
       --database-name string                  The name of the Yucca database (default "yucca")
       --database-password string              The database user's password (not applicable for sqlite3) (default "postgres")
       --database-path string                  SQLite database location
       --database-ssl-mode string              SSL mode for Postgres (disable, require or verify-full) (default "disable")
       --database-user string                  The database user (not applicable for sqlite3) (default "postgres")
   -h, --help                                  Help for migrate
       --state-dir string                      The directory used to store state and other persistent data (default "<data-dir>/state")

   ```

4. Informe na [configuração](https://yucca.app/pt/docs/configuration.md#database) o novo tipo de banco de dados **postgres** e informe as credenciais de conexão.

5. Inicie o servidor Yucca:

   ```sh
   sudo systemctl start yucca

   ```

6. Certifique-se de que o Yucca agora está usando o **postgres**; isso pode ser visto na seção de configuração `/ui/administration/config` ou no log durante a inicialização do servidor.
