Este conteúdo não está disponível no idioma selecionado.
Chapter 18. Backing up and restoring Red Hat Quay on a standalone deployment
Use the content within this section to back up and restore Red Hat Quay in standalone deployments.
18.1. Backing up Red Hat Quay on standalone deployments Copiar o linkLink copiado para a área de transferência!
This procedure describes how to create a backup of Red Hat Quay on standalone deployments.
Procedure
Create a temporary backup directory, for example,
quay-backup:mkdir /tmp/quay-backup
$ mkdir /tmp/quay-backupCopy to Clipboard Copied! Toggle word wrap Toggle overflow The following example command denotes the local directory that the Red Hat Quay was started in, for example,
/opt/quay-install:podman run --name quay-app \ -v /opt/quay-install/config:/conf/stack:Z \ -v /opt/quay-install/storage:/datastorage:Z \ registry.redhat.io/quay/quay-rhel8:v3.8.15
$ podman run --name quay-app \ -v /opt/quay-install/config:/conf/stack:Z \ -v /opt/quay-install/storage:/datastorage:Z \ registry.redhat.io/quay/quay-rhel8:v3.8.15Copy to Clipboard Copied! Toggle word wrap Toggle overflow Change into the directory that bind-mounts to
/conf/stackinside of the container, for example,/opt/quay-install, by running the following command:cd /opt/quay-install
$ cd /opt/quay-installCopy to Clipboard Copied! Toggle word wrap Toggle overflow Compress the contents of your Red Hat Quay deployment into an archive in the
quay-backupdirectory by entering the following command:tar cvf /tmp/quay-backup/quay-backup.tar.gz *
$ tar cvf /tmp/quay-backup/quay-backup.tar.gz *Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Back up the Quay container service by entering the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Redirect the contents of your
conf/stack/config.yamlfile to your temporaryquay-config.yamlfile by entering the following command:podman exec -it quay cat /conf/stack/config.yaml > /tmp/quay-backup/quay-config.yaml
$ podman exec -it quay cat /conf/stack/config.yaml > /tmp/quay-backup/quay-config.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Obtain the
DB_URIlocated in your temporaryquay-config.yamlby entering the following command:grep DB_URI /tmp/quay-backup/quay-config.yaml
$ grep DB_URI /tmp/quay-backup/quay-config.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
postgresql://<username>:test123@172.24.10.50/quay
$ postgresql://<username>:test123@172.24.10.50/quayCopy to Clipboard Copied! Toggle word wrap Toggle overflow Extract the PostgreSQL contents to your temporary backup directory in a backup .sql file by entering the following command:
pg_dump -h 172.24.10.50 -p 5432 -d quay -U <username> -W -O > /tmp/quay-backup/quay-backup.sql
$ pg_dump -h 172.24.10.50 -p 5432 -d quay -U <username> -W -O > /tmp/quay-backup/quay-backup.sqlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Print the contents of your
DISTRIBUTED_STORAGE_CONFIGby entering the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Export the
AWS_ACCESS_KEY_IDby using theaccess_keycredential obtained in Step 7:export AWS_ACCESS_KEY_ID=<access_key>
$ export AWS_ACCESS_KEY_ID=<access_key>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Export the
AWS_SECRET_ACCESS_KEYby using thesecret_keyobtained in Step 7:export AWS_SECRET_ACCESS_KEY=<secret_key>
$ export AWS_SECRET_ACCESS_KEY=<secret_key>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Sync the
quaybucket to the/tmp/quay-backup/blob-backup/directory from thehostnameof yourDISTRIBUTED_STORAGE_CONFIG:aws s3 sync s3://<bucket_name> /tmp/quay-backup/blob-backup/ --source-region us-east-2
$ aws s3 sync s3://<bucket_name> /tmp/quay-backup/blob-backup/ --source-region us-east-2Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
download: s3://<user_name>/registry/sha256/9c/9c3181779a868e09698b567a3c42f3744584ddb1398efe2c4ba569a99b823f7a to registry/sha256/9c/9c3181779a868e09698b567a3c42f3744584ddb1398efe2c4ba569a99b823f7a download: s3://<user_name>/registry/sha256/e9/e9c5463f15f0fd62df3898b36ace8d15386a6813ffb470f332698ecb34af5b0d to registry/sha256/e9/e9c5463f15f0fd62df3898b36ace8d15386a6813ffb470f332698ecb34af5b0d
download: s3://<user_name>/registry/sha256/9c/9c3181779a868e09698b567a3c42f3744584ddb1398efe2c4ba569a99b823f7a to registry/sha256/9c/9c3181779a868e09698b567a3c42f3744584ddb1398efe2c4ba569a99b823f7a download: s3://<user_name>/registry/sha256/e9/e9c5463f15f0fd62df3898b36ace8d15386a6813ffb470f332698ecb34af5b0d to registry/sha256/e9/e9c5463f15f0fd62df3898b36ace8d15386a6813ffb470f332698ecb34af5b0dCopy to Clipboard Copied! Toggle word wrap Toggle overflow
It is recommended that you delete the quay-config.yaml file after syncing the quay bucket because it contains sensitive information. The quay-config.yaml file will not be lost because it is backed up in the quay-backup.tar.gz file.
18.2. Restoring Red Hat Quay on standalone deployments Copiar o linkLink copiado para a área de transferência!
This procedure describes how to restore Red Hat Quay on standalone deployments.
Prerequisites
- You have backed up your Red Hat Quay deployment.
Procedure
Create a new directory that will bind-mount to
/conf/stackinside of the Red Hat Quay container:mkdir /opt/new-quay-install
$ mkdir /opt/new-quay-installCopy to Clipboard Copied! Toggle word wrap Toggle overflow Copy the contents of your temporary backup directory created in Backing up Red Hat Quay on standalone deployments to the
new-quay-install1directory created in Step 1:cp /tmp/quay-backup/quay-backup.tar.gz /opt/new-quay-install/
$ cp /tmp/quay-backup/quay-backup.tar.gz /opt/new-quay-install/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Change into the
new-quay-installdirectory by entering the following command:cd /opt/new-quay-install/
$ cd /opt/new-quay-install/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Extract the contents of your Red Hat Quay directory:
tar xvf /tmp/quay-backup/quay-backup.tar.gz *
$ tar xvf /tmp/quay-backup/quay-backup.tar.gz *Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Recall the
DB_URIfrom your backed-upconfig.yamlfile by entering the following command:grep DB_URI config.yaml
$ grep DB_URI config.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
postgresql://<username>:test123@172.24.10.50/quay
postgresql://<username>:test123@172.24.10.50/quayCopy to Clipboard Copied! Toggle word wrap Toggle overflow Run the following command to enter the PostgreSQL database server:
sudo postgres
$ sudo postgresCopy to Clipboard Copied! Toggle word wrap Toggle overflow Enter psql and create a new database in 172.24.10.50 to restore the quay databases, for example,
example_restore_registry_quay_database, by entering the following command:psql "host=172.24.10.50 port=5432 dbname=postgres user=<username> password=test123" postgres=> CREATE DATABASE example_restore_registry_quay_database;
$ psql "host=172.24.10.50 port=5432 dbname=postgres user=<username> password=test123" postgres=> CREATE DATABASE example_restore_registry_quay_database;Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
CREATE DATABASE
CREATE DATABASECopy to Clipboard Copied! Toggle word wrap Toggle overflow Connect to the database by running the following command:
postgres=# \c "example-restore-registry-quay-database";
postgres=# \c "example-restore-registry-quay-database";Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
You are now connected to database "example-restore-registry-quay-database" as user "postgres".
You are now connected to database "example-restore-registry-quay-database" as user "postgres".Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a
pg_trmgextension of your Quay database by running the following command:example_restore_registry_quay_database=> CREATE EXTENSION IF NOT EXISTS pg_trgm;
example_restore_registry_quay_database=> CREATE EXTENSION IF NOT EXISTS pg_trgm;Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
CREATE EXTENSION
CREATE EXTENSIONCopy to Clipboard Copied! Toggle word wrap Toggle overflow Exit the postgres CLI by entering the following command:
\q
\qCopy to Clipboard Copied! Toggle word wrap Toggle overflow Import the database backup to your new database by running the following command:
psql "host=172.24.10.50 port=5432 dbname=example_restore_registry_quay_database user=<username> password=test123" -W < /tmp/quay-backup/quay-backup.sql
$ psql "host=172.24.10.50 port=5432 dbname=example_restore_registry_quay_database user=<username> password=test123" -W < /tmp/quay-backup/quay-backup.sqlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
SET SET SET SET SET
SET SET SET SET SETCopy to Clipboard Copied! Toggle word wrap Toggle overflow Update the value of
DB_URIin yourconfig.yamlfrompostgresql://<username>:test123@172.24.10.50/quaytopostgresql://<username>:test123@172.24.10.50/example-restore-registry-quay-databasebefore restarting the Red Hat Quay deployment.NoteThe DB_URI format is
DB_URI postgresql://<login_user_name>:<login_user_password>@<postgresql_host>/<quay_database>. If you are moving from one PostgreSQL server to another PostgreSQL server, update the value of<login_user_name>,<login_user_password>and<postgresql_host>at the same time.In the
/opt/new-quay-installdirectory, print the contents of yourDISTRIBUTED_STORAGE_CONFIGbundle:cat config.yaml | grep DISTRIBUTED_STORAGE_CONFIG -A10
$ cat config.yaml | grep DISTRIBUTED_STORAGE_CONFIG -A10Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteYour
DISTRIBUTED_STORAGE_CONFIGin/opt/new-quay-installmust be updated before restarting your Red Hat Quay deployment.Export the
AWS_ACCESS_KEY_IDby using theaccess_keycredential obtained in Step 13:export AWS_ACCESS_KEY_ID=<access_key>
$ export AWS_ACCESS_KEY_ID=<access_key>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Export the
AWS_SECRET_ACCESS_KEYby using thesecret_keyobtained in Step 13:export AWS_SECRET_ACCESS_KEY=<secret_key>
$ export AWS_SECRET_ACCESS_KEY=<secret_key>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a new s3 bucket by entering the following command:
aws s3 mb s3://<new_bucket_name> --region us-east-2
$ aws s3 mb s3://<new_bucket_name> --region us-east-2Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
make_bucket: quay
$ make_bucket: quayCopy to Clipboard Copied! Toggle word wrap Toggle overflow Upload all blobs to the new s3 bucket by entering the following command:
aws s3 sync --no-verify-ssl \ --endpoint-url <example_endpoint_url> /tmp/quay-backup/blob-backup/. s3://quay/
$ aws s3 sync --no-verify-ssl \ --endpoint-url <example_endpoint_url>1 /tmp/quay-backup/blob-backup/. s3://quay/Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The Red Hat Quay registry endpoint must be the same before backup and after restore.
Example output:
upload: ../../tmp/quay-backup/blob-backup/datastorage/registry/sha256/50/505edb46ea5d32b5cbe275eb766d960842a52ee77ac225e4dc8abb12f409a30d to s3://quay/datastorage/registry/sha256/50/505edb46ea5d32b5cbe275eb766d960842a52ee77ac225e4dc8abb12f409a30d upload: ../../tmp/quay-backup/blob-backup/datastorage/registry/sha256/27/27930dc06c2ee27ac6f543ba0e93640dd21eea458eac47355e8e5989dea087d0 to s3://quay/datastorage/registry/sha256/27/27930dc06c2ee27ac6f543ba0e93640dd21eea458eac47355e8e5989dea087d0 upload: ../../tmp/quay-backup/blob-backup/datastorage/registry/sha256/8c/8c7daf5e20eee45ffe4b36761c4bb6729fb3ee60d4f588f712989939323110ec to s3://quay/datastorage/registry/sha256/8c/8c7daf5e20eee45ffe4b36761c4bb6729fb3ee60d4f588f712989939323110ec ...
upload: ../../tmp/quay-backup/blob-backup/datastorage/registry/sha256/50/505edb46ea5d32b5cbe275eb766d960842a52ee77ac225e4dc8abb12f409a30d to s3://quay/datastorage/registry/sha256/50/505edb46ea5d32b5cbe275eb766d960842a52ee77ac225e4dc8abb12f409a30d upload: ../../tmp/quay-backup/blob-backup/datastorage/registry/sha256/27/27930dc06c2ee27ac6f543ba0e93640dd21eea458eac47355e8e5989dea087d0 to s3://quay/datastorage/registry/sha256/27/27930dc06c2ee27ac6f543ba0e93640dd21eea458eac47355e8e5989dea087d0 upload: ../../tmp/quay-backup/blob-backup/datastorage/registry/sha256/8c/8c7daf5e20eee45ffe4b36761c4bb6729fb3ee60d4f588f712989939323110ec to s3://quay/datastorage/registry/sha256/8c/8c7daf5e20eee45ffe4b36761c4bb6729fb3ee60d4f588f712989939323110ec ...Copy to Clipboard Copied! Toggle word wrap Toggle overflow Before restarting your Red Hat Quay deployment, update the storage settings in your config.yaml:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow