This repository demonstrates how to use .cnb.yml endStages and Tencent Cloud COS to implement persistent storage for Postgres in cloud development environments.
During cloud development environment shutdown phase, the tencentcom/coscli plugin is used to synchronize specified directories to COS object storage. During startup phase, data from COS object storage is restored to specified directories, achieving data persistence.
The storage path in COS object storage is: /{reponame}/{branchname}
The secret repository imported in .cnb.yml contains:
SECRET_ID: AKIDxxxxx SECRET_KEY: yyyyyy REGION: ap-guangzhou BUCKET: cnb-vvvv
After startup, you can connect to the database and test using:
docker exec -it workspace-postgres-1 psql -U testuser -d testdb