logo
0
0
WeChat Login
Add backup-to-cloud command

Codebuddy Command, /backup-to-cloud

Prerequisite - Setting up Tencent Cloud COS

Concepts and Terminology

https://cloud.tencent.com/document/product/436/56390

Steps

  1. Create a new sub user, https://console.cloud.tencent.com/cam/user/userType
  2. Enter this sub user details.
  • Add a policy, called "QcloudCOSFullAccess"
  • Create a new SecretId and SecretKey pair. Better add remark for further reference
  1. Create a new bucket, https://console.cloud.tencent.com/cos/bucket
  • Private Read/Write (Important!)
  • Optional, version control
  1. Permission control, add sub user to this bucket. https://console.cloud.tencent.com/cos/bucket?bucket=&region=&type=aclconfig

Avoid Using Master Account API Access Keys

Security Advisory Master Account API keys grant full control over all cloud resources associated with the account. If compromised due to improper handling, this could lead to severe security incidents—such as server intrusion, or the encryption (via ransomware) or deletion of critical data assets—and would prevent the rapid containment of damage through the immediate restriction of permissions.

Recommendation 1: Use Temporary Credentials Instead of API Keys

It is recommended to utilize an STS Token-based temporary credential scheme for programmatic access. Temporary credentials feature an automatic expiration mechanism, thereby fundamentally mitigating the security risks associated with long-term exposure.

Except expiration, STS approach avoids exposing permanent keys to clients. qcloud-cos-sts-sdk can be used to create you own STS service.

Recommendation 2: Use Sub-user API Keys Instead of Master Account API Keys

If the use of an API key is absolutely necessary, it is recommended to use a sub-user key. Furthermore, adhere to the "Principle of Least Privilege" by precisely configuring only the specific permissions required for the sub-user, thereby effectively isolating security risks.

How To Use

Add environment variables

Codebuddy Code setting locaion

  • MacOS or Linux, ~/.codebuddy/settings.json
  • Windows, C:\Users<username>.codebuddy\settings.json

Add four environment variables, see the prerequisite above.

{
  "env": {
    "TENCENTCLOUD_SECRET_ID": "",
    "TENCENTCLOUD_SECRET_KEY": "",
    "TENCENTCLOUD_REGION": "",
    "TENCENTCLOUD_COS_BUCKET": ""
  }
}

Add command

Find the latest release from here and download compressed file

Unzip backup-to-cloud.md and backup-to-cloud in compressed file to loaction

  • MacOS or Linux, ~/.codebuddy/commands
  • Windows, C:\Users<username>.codebuddy\commands

Structure shown below

├── .codebuddy
│   ├── commands
│   │   ├── backup-to-cloud     # Scripts needed
│   │   ├── backup-to-cloud.md  # Command description

Example

  1. Open Codebuddy Code
  2. Typing /export. Choose second options, save to file. Enter the file name, e.g. conversation.txt
  3. Typing /backup-to-cloud conversation.txt. Then it will be saved to cloud.