Backup and restore#

Caution

Open a support ticket to get assistance from Anaconda if you are upgrading your operating system or plan on migrating your instance of Package Security Manager (On-prem) to a new operating system architecture, as this could severely impact your Package Security Manager instance!

Prerequisites#

  • pg_dump version 9.6.4+

  • pg_restore version 9.6.4+

  • Linux’s open file maximum must be set to 300,000

    Increasing the Open File Limit in Linux

    To increase the number of files that are allowed to be open at once in Linux, run the following command:

    sysctl -w fs.file-max=300000
    

Backing up Package Security Manager#

Follow these steps to back up your instance of Package Security Manager:

  1. Open a terminal and connect to your instance of Package Security Manager. Work with your IT administrator if you need help with this step.

  2. Enter your installer directory.

  3. Using your preferred file editor, open the docker-compose.yml file.

  4. Locate the Postgres: expose: section of the file.

  5. Replace expose with ports, and replace "5432" with "5432:5432".

  6. Save your work and close the file.

  7. Restart your containers by running the following command:

    docker compose up -d
    
  8. Create a backup of the docker-compose.yml and .env files. These files contain your server’s custom configurations and are overwritten during reinstallation.

  9. Run the following command from the install directory:

    # Replace <POSTGRES_PASSWORD> with your postgres password. You can find your postgres password here: <BASE_INSTALL_DIR>/config/postgres/postgres_db_password.txt
    ./repo-tools backup --database-uri postgresql://postgres:<POSTGRES_PASSWORD>@localhost:5432/postgres --keycloak-database-uri postgresql://postgres:<POSTGRES_PASSWORD>@localhost:5432/keycloak  --blob-dir /opt/anaconda/repo/state/internal/blobs/ > repo.backup.zip
    
  10. Save the repo.backup.zip file to a secure location.

  11. Open your docker-compose.yml file.

  12. Revert the changes to the Postgres: expose: section of the file and restore your server’s custom configurations.

  13. Save your changes and close the file.

  14. Open the .env file and restore your server’s saved custom configurations.

  15. Save your changes and close the file.

  16. Restart your containers by running the following command:

    docker compose up -d
    

Restoring Package Security Manager#

Follow these steps to restore your instance of Package Security Manager:

  1. Reinstall Package Security Manager (On-prem).

  2. Open a terminal and connect to your instance of Package Security Manager. Get help from your IT administrator if you need help with this step.

  3. Enter your installer directory.

  4. Using your preferred file editor, open the docker-compose.yml file.

  5. Locate the Postgres: expose: section of the file.

  6. Replace expose with ports, and replace "5432" with "5432:5432".

  7. Save your work and close the file.

  8. Restart your containers by running the following command:

    docker compose up -d
    
  9. Copy the repo.backup.zip file.

  10. Run the following command from the install directory:

    # Replace <POSTGRES_PASSWORD> with your postgres password. You can find your postgres password here: <BASE_INSTALL_DIR>/config/postgres/postgres_db_password.txt
    ./repo-tools restore repo.backup.zip --database-uri postgresql://postgres:<POSTGRES_PASSWORD>@localhost:5432/postgres --keycloak-database-uri postgresql://postgres:<POSTGRES_PASSWORD>@localhost:5432/keycloak --blob-dir /opt/anaconda/repo/state/internal/blobs/
    
  11. Open your docker-compose.yml file.

  12. Revert the changes to the Postgres: expose: section of the file and restore your server’s custom configurations.

  13. Save your changes and close the file.

  14. Open the .env file and restore your server’s custom configurations.

  15. Save your changes and close the file.

  16. Run the following in the install directory:

    docker compose up -d repo_api