pingcap / tidb

TiDB is an open-source, cloud-native, distributed, MySQL-Compatible database for elastic scale and real-time analytics. Try AI-powered Chat2Query free at : https://www.pingcap.com/tidb-serverless/
https://pingcap.com
Apache License 2.0
36.8k stars 5.8k forks source link

Kubernetes - BackupSchedule - maxBackups or maxReservedTime dont work #20083

Open Mertonidas opened 3 years ago

Mertonidas commented 3 years ago

General Question

Hi,

I have installed a tidb-cluster using tidb-operator and tidb-cluster CRD. I'm using the BackupSchedule CRD with BR to take backups of tidb-cluster. I use minio as remote S3 storage, and the backups work well.

https://docs.pingcap.com/tidb-in-kubernetes/stable/backup-to-aws-s3-using-br

In the documentation appears the parameter .spec.maxBackups in the BackupSchedule CRD which determines the maximum number of backup items to be retained.

I set up maxBackups to 5. Means it that in minio will be storage just the last 5 backups and older will be deleted?

This is my BackupSchedule definition for testing purpose:

apiVersion: pingcap.com/v1alpha1
kind: BackupSchedule
metadata:
  name: tidb-schedule-backup-minio
  namespace: dev-iot
spec:
  #pause: true
  #maxReservedTime: "3h"
  maxBackups: 5
  schedule: "*/5 * * * *"
  backupTemplate:
    backupType: full
    br:
      cluster: tidb-cluster
      clusterNamespace: dev-iot
      # logLevel: info
      # statusAddr: ${status_addr}
      # concurrency: 4
      # rateLimit: 0
      # timeAgo: ${time}
      # checksum: true
      # sendCredToTikv: true
    from:
      host: tidb-cluster-tidb
      port: 4000
      user: root
      secretName: backup-tidb-secret
    s3:
      provider: minio
      endpoint: http://minio-azure-gateway:9000
      secretName: minio-backup-secret
      bucket: tidb-backup

This is the log of backup-tidb-schedule-backup-minio pod:

2020-09-17T12:38:24.257169855Z Create rclone.conf file.
2020-09-17T12:38:24.259520029Z /tidb-backup-manager backup --namespace=namespace --backupName=tidb-schedule-backup-minio-2020-09-17t12-38-00 --tikvVersion=v4.0.4
2020-09-17T12:38:25.403821843Z I0917 12:38:25.403588       1 backup.go:71] start to process backup namespace/tidb-schedule-backup-minio-2020-09-17t12-38-00
2020-09-17T12:38:25.424932108Z I0917 12:38:25.424785       1 backup_status_updater.go:64] Backup: [namespace/tidb-schedule-backup-minio-2020-09-17t12-38-00] updated successfully
2020-09-17T12:38:25.453978461Z I0917 12:38:25.453850       1 backup_status_updater.go:64] Backup: [namespace/tidb-schedule-backup-minio-2020-09-17t12-38-00] updated successfully
2020-09-17T12:38:25.462776613Z I0917 12:38:25.462619       1 manager.go:176] cluster namespace/tidb-schedule-backup-minio-2020-09-17t12-38-00 tikv_gc_life_time is 10m0s
2020-09-17T12:38:25.483227328Z I0917 12:38:25.483099       1 manager.go:240] set cluster namespace/tidb-schedule-backup-minio-2020-09-17t12-38-00 tikv_gc_life_time to 72h success
2020-09-17T12:38:25.48324333Z I0917 12:38:25.483130       1 backup.go:65] Running br command with args: [backup full --storage=s3://tidb-backup/tidb-cluster-pd.namespace-2379-2020-09-17t12-38-00/ --s3.provider=minio --s3.endpoint=http://minio-azure-gateway:9000 --pd=tidb-cluster-pd.namespace:2379]
2020-09-17T12:38:25.509032941Z I0917 12:38:25.508819       1 backup.go:89] [2020/09/17 12:38:25.508 +00:00] [INFO] [version.go:33] ["Welcome to Backup & Restore (BR)"]
2020-09-17T12:38:25.509053443Z I0917 12:38:25.508842       1 backup.go:89] [2020/09/17 12:38:25.508 +00:00] [INFO] [version.go:34] [BR] [release-version=v4.0.4]
2020-09-17T12:38:25.509057543Z I0917 12:38:25.508848       1 backup.go:89] [2020/09/17 12:38:25.508 +00:00] [INFO] [version.go:35] [BR] [git-hash=c91c79a8431805dcbfda2c7b2612dde6985e564c]
2020-09-17T12:38:25.509060743Z I0917 12:38:25.508852       1 backup.go:89] [2020/09/17 12:38:25.508 +00:00] [INFO] [version.go:36] [BR] [git-branch=heads/refs/tags/v4.0.4]
2020-09-17T12:38:25.509064043Z I0917 12:38:25.508859       1 backup.go:89] [2020/09/17 12:38:25.508 +00:00] [INFO] [version.go:37] [BR] [go-version=go1.13]
2020-09-17T12:38:25.509067144Z I0917 12:38:25.508863       1 backup.go:89] [2020/09/17 12:38:25.508 +00:00] [INFO] [version.go:38] [BR] [utc-build-time="2020-07-31 07:33:17"]
2020-09-17T12:38:25.509070344Z I0917 12:38:25.508867       1 backup.go:89] [2020/09/17 12:38:25.508 +00:00] [INFO] [version.go:39] [BR] [race-enabled=false]
2020-09-17T12:38:25.509073344Z I0917 12:38:25.508872       1 backup.go:89] [2020/09/17 12:38:25.508 +00:00] [INFO] [common.go:381] [arguments] [pd="[tidb-cluster-pd.namespace:2379]"] [s3.endpoint=http://minio-azure-gateway:9000] [s3.provider=minio] [storage=s3://tidb-backup/tidb-cluster-pd.namespace-2379-2020-09-17t12-38-00/]
2020-09-17T12:38:25.509077144Z I0917 12:38:25.508933       1 backup.go:89] [2020/09/17 12:38:25.508 +00:00] [INFO] [client.go:149] ["[pd] create pd client with endpoints"] [pd-address="[tidb-cluster-pd.namespace:2379]"]
2020-09-17T12:38:25.515174196Z I0917 12:38:25.514859       1 backup.go:89] [2020/09/17 12:38:25.514 +00:00] [INFO] [base_client.go:226] ["[pd] update member urls"] [old-urls="[http://tidb-cluster-pd.namespace:2379]"] [new-urls="[http://tidb-cluster-pd-0.tidb-cluster-pd-peer.namespace.svc:2379,http://tidb-cluster-pd-1.tidb-cluster-pd-peer.namespace.svc:2379,http://tidb-cluster-pd-2.tidb-cluster-pd-peer.namespace.svc:2379]"]
2020-09-17T12:38:25.515254102Z I0917 12:38:25.514900       1 backup.go:89] [2020/09/17 12:38:25.514 +00:00] [INFO] [base_client.go:242] ["[pd] switch leader"] [new-leader=http://tidb-cluster-pd-1.tidb-cluster-pd-peer.namespace.svc:2379] [old-leader=]
2020-09-17T12:38:25.515259303Z I0917 12:38:25.514915       1 backup.go:89] [2020/09/17 12:38:25.514 +00:00] [INFO] [base_client.go:92] ["[pd] init cluster id"] [cluster-id=6870115696503757026]
2020-09-17T12:38:25.533259137Z I0917 12:38:25.533085       1 backup.go:89] [2020/09/17 12:38:25.532 +00:00] [INFO] [client.go:149] ["[pd] create pd client with endpoints"] [pd-address="[tidb-cluster-pd.namespace:2379]"]
2020-09-17T12:38:25.540805096Z I0917 12:38:25.540681       1 backup.go:89] [2020/09/17 12:38:25.540 +00:00] [INFO] [base_client.go:226] ["[pd] update member urls"] [old-urls="[http://tidb-cluster-pd.namespace:2379]"] [new-urls="[http://tidb-cluster-pd-0.tidb-cluster-pd-peer.namespace.svc:2379,http://tidb-cluster-pd-1.tidb-cluster-pd-peer.namespace.svc:2379,http://tidb-cluster-pd-2.tidb-cluster-pd-peer.namespace.svc:2379]"]
2020-09-17T12:38:25.540823897Z I0917 12:38:25.540704       1 backup.go:89] [2020/09/17 12:38:25.540 +00:00] [INFO] [base_client.go:242] ["[pd] switch leader"] [new-leader=http://tidb-cluster-pd-1.tidb-cluster-pd-peer.namespace.svc:2379] [old-leader=]
2020-09-17T12:38:25.541479246Z I0917 12:38:25.541364       1 backup.go:89] [2020/09/17 12:38:25.540 +00:00] [INFO] [base_client.go:92] ["[pd] init cluster id"] [cluster-id=6870115696503757026]
2020-09-17T12:38:25.547455689Z I0917 12:38:25.547360       1 backup.go:89] [2020/09/17 12:38:25.547 +00:00] [INFO] [conn.go:206] ["new mgr"] [pdAddrs=tidb-cluster-pd.namespace:2379]
2020-09-17T12:38:25.548539369Z I0917 12:38:25.548314       1 backup.go:89] [2020/09/17 12:38:25.548 +00:00] [INFO] [tidb.go:71] ["new domain"] [store=tikv-6870115696503757026] ["ddl lease"=1s] ["stats lease"=-1ns]
2020-09-17T12:38:25.551723705Z I0917 12:38:25.551608       1 backup.go:89] [2020/09/17 12:38:25.551 +00:00] [INFO] [ddl.go:316] ["[ddl] start DDL"] [ID=67c516bd-f53f-4748-93e4-bee3277c0605] [runWorker=false]
2020-09-17T12:38:25.598008236Z I0917 12:38:25.597865       1 backup.go:89] [2020/09/17 12:38:25.597 +00:00] [INFO] [domain.go:145] ["full load InfoSchema success"] [usedSchemaVersion=0] [neededSchemaVersion=85] ["start time"=6.971817ms]
2020-09-17T12:38:25.601258977Z I0917 12:38:25.601147       1 backup.go:89] [2020/09/17 12:38:25.601 +00:00] [INFO] [domain.go:369] ["full load and reset schema validator"]
2020-09-17T12:38:25.601273078Z I0917 12:38:25.601183       1 backup.go:89] [2020/09/17 12:38:25.601 +00:00] [INFO] [client.go:77] ["new backup client"]
2020-09-17T12:38:25.731685944Z I0917 12:38:25.731538       1 backup.go:89] [2020/09/17 12:38:25.731 +00:00] [INFO] [client.go:121] ["backup encode timestamp"] [BackupTS=419521181966401538]
2020-09-17T12:38:25.731712946Z I0917 12:38:25.731564       1 backup.go:89] [2020/09/17 12:38:25.731 +00:00] [INFO] [backup.go:159] ["current backup safePoint job"] [safepoint=419521181966401538]
2020-09-17T12:38:25.737670487Z I0917 12:38:25.737557       1 backup.go:89] [2020/09/17 12:38:25.737 +00:00] [INFO] [domain.go:145] ["full load InfoSchema success"] [usedSchemaVersion=0] [neededSchemaVersion=85] ["start time"=5.310893ms]
2020-09-17T12:38:25.742983981Z I0917 12:38:25.742830       1 backup.go:89] [2020/09/17 12:38:25.742 +00:00] [INFO] [client.go:294] ["change table AutoIncID"] [db=dummydb] [table=some_service_properties] [AutoIncID=6]
2020-09-17T12:38:25.743699834Z I0917 12:38:25.743577       1 backup.go:89] [2020/09/17 12:38:25.743 +00:00] [INFO] [client.go:294] ["change table AutoIncID"] [db=dummydb] [table=some] [AutoIncID=90113]
2020-09-17T12:38:25.74485552Z I0917 12:38:25.744655       1 backup.go:89] [2020/09/17 12:38:25.744 +00:00] [INFO] [client.go:294] ["change table AutoIncID"] [db=dummydb] [table=metasome] [AutoIncID=108190]
2020-09-17T12:38:25.768267155Z I0917 12:38:25.768111       1 backup.go:89] [2020/09/17 12:38:25.768 +00:00] [INFO] [client.go:476] ["backup started"] [StartKey=7480000000000000615f720000000000000000] [EndKey=7480000000000000615f72ffffffffffffffff00] [RateLimit=0] [Concurrency=4]
2020-09-17T12:38:25.768287257Z I0917 12:38:25.768136       1 backup.go:89] [2020/09/17 12:38:25.768 +00:00] [INFO] [client.go:476] ["backup started"] [StartKey=74800000000000005f5f720000000000000000] [EndKey=74800000000000005f5f72ffffffffffffffff00] [RateLimit=0] [Concurrency=4]
2020-09-17T12:38:25.768291757Z I0917 12:38:25.768143       1 backup.go:89] [2020/09/17 12:38:25.768 +00:00] [INFO] [client.go:476] ["backup started"] [StartKey=74800000000000005d5f720000000000000000] [EndKey=74800000000000005d5f72ffffffffffffffff00] [RateLimit=0] [Concurrency=4]
2020-09-17T12:38:25.768295657Z I0917 12:38:25.768153       1 backup.go:89] [2020/09/17 12:38:25.768 +00:00] [INFO] [client.go:476] ["backup started"] [StartKey=74800000000000005f5f69800000000000000100] [EndKey=74800000000000005f5f698000000000000001fb] [RateLimit=0] [Concurrency=4]
2020-09-17T12:38:25.768688086Z I0917 12:38:25.768593       1 backup.go:89] [2020/09/17 12:38:25.768 +00:00] [INFO] [push.go:29] ["new backup client"]
2020-09-17T12:38:25.768702087Z I0917 12:38:25.768614       1 backup.go:89] [2020/09/17 12:38:25.768 +00:00] [INFO] [push.go:29] ["new backup client"]
2020-09-17T12:38:25.768706288Z I0917 12:38:25.768623       1 backup.go:89] [2020/09/17 12:38:25.768 +00:00] [INFO] [push.go:29] ["new backup client"]
2020-09-17T12:38:25.768778593Z I0917 12:38:25.768694       1 backup.go:89] [2020/09/17 12:38:25.768 +00:00] [INFO] [push.go:29] ["new backup client"]
2020-09-17T12:38:25.769394439Z I0917 12:38:25.769283       1 backup.go:89] [2020/09/17 12:38:25.769 +00:00] [INFO] [client.go:794] ["try backup"] [StartKey=74800000000000005f5f69800000000000000100] [EndKey=74800000000000005f5f698000000000000001fb] [storeID=1]
2020-09-17T12:38:25.769905877Z I0917 12:38:25.769811       1 backup.go:89] [2020/09/17 12:38:25.769 +00:00] [INFO] [client.go:794] ["try backup"] [StartKey=74800000000000005f5f69800000000000000100] [EndKey=74800000000000005f5f698000000000000001fb] [storeID=4]
2020-09-17T12:38:25.770366611Z I0917 12:38:25.770242       1 backup.go:89] [2020/09/17 12:38:25.770 +00:00] [INFO] [client.go:794] ["try backup"] [StartKey=7480000000000000615f720000000000000000] [EndKey=7480000000000000615f72ffffffffffffffff00] [storeID=1]
2020-09-17T12:38:25.770382112Z I0917 12:38:25.770261       1 backup.go:89] [2020/09/17 12:38:25.770 +00:00] [INFO] [client.go:794] ["try backup"] [StartKey=74800000000000005f5f720000000000000000] [EndKey=74800000000000005f5f72ffffffffffffffff00] [storeID=1]
2020-09-17T12:38:25.770388712Z I0917 12:38:25.770270       1 backup.go:89] [2020/09/17 12:38:25.770 +00:00] [INFO] [client.go:794] ["try backup"] [StartKey=74800000000000005f5f69800000000000000100] [EndKey=74800000000000005f5f698000000000000001fb] [storeID=5]
2020-09-17T12:38:25.770403914Z I0917 12:38:25.770309       1 backup.go:89] [2020/09/17 12:38:25.770 +00:00] [INFO] [client.go:794] ["try backup"] [StartKey=74800000000000005d5f720000000000000000] [EndKey=74800000000000005d5f72ffffffffffffffff00] [storeID=4]
2020-09-17T12:38:25.770413514Z I0917 12:38:25.770352       1 backup.go:89] [2020/09/17 12:38:25.770 +00:00] [INFO] [client.go:794] ["try backup"] [StartKey=74800000000000005d5f720000000000000000] [EndKey=74800000000000005d5f72ffffffffffffffff00] [storeID=5]
2020-09-17T12:38:25.77049502Z I0917 12:38:25.770415       1 backup.go:89] [2020/09/17 12:38:25.770 +00:00] [INFO] [client.go:794] ["try backup"] [StartKey=74800000000000005f5f720000000000000000] [EndKey=74800000000000005f5f72ffffffffffffffff00] [storeID=4]
2020-09-17T12:38:25.770505421Z I0917 12:38:25.770430       1 backup.go:89] [2020/09/17 12:38:25.770 +00:00] [INFO] [client.go:794] ["try backup"] [StartKey=7480000000000000615f720000000000000000] [EndKey=7480000000000000615f72ffffffffffffffff00] [storeID=5]
2020-09-17T12:38:25.770547524Z I0917 12:38:25.770434       1 backup.go:89] [2020/09/17 12:38:25.770 +00:00] [INFO] [client.go:794] ["try backup"] [StartKey=74800000000000005d5f720000000000000000] [EndKey=74800000000000005d5f72ffffffffffffffff00] [storeID=1]
2020-09-17T12:38:25.770555725Z I0917 12:38:25.770447       1 backup.go:89] [2020/09/17 12:38:25.770 +00:00] [INFO] [client.go:794] ["try backup"] [StartKey=7480000000000000615f720000000000000000] [EndKey=7480000000000000615f72ffffffffffffffff00] [storeID=4]
2020-09-17T12:38:25.770565025Z I0917 12:38:25.770451       1 backup.go:89] [2020/09/17 12:38:25.770 +00:00] [INFO] [client.go:794] ["try backup"] [StartKey=74800000000000005f5f720000000000000000] [EndKey=74800000000000005f5f72ffffffffffffffff00] [storeID=5]
2020-09-17T12:38:25.807944096Z I0917 12:38:25.807832       1 backup.go:89] [2020/09/17 12:38:25.807 +00:00] [INFO] [client.go:810] ["backup streaming finish"] [StoreID=1]
2020-09-17T12:38:25.807959397Z I0917 12:38:25.807855       1 backup.go:89] [2020/09/17 12:38:25.807 +00:00] [INFO] [client.go:810] ["backup streaming finish"] [StoreID=1]
2020-09-17T12:38:25.807963397Z I0917 12:38:25.807863       1 backup.go:89] [2020/09/17 12:38:25.807 +00:00] [INFO] [client.go:810] ["backup streaming finish"] [StoreID=1]
2020-09-17T12:38:25.807966998Z I0917 12:38:25.807873       1 backup.go:89] [2020/09/17 12:38:25.807 +00:00] [INFO] [client.go:810] ["backup streaming finish"] [StoreID=1]
2020-09-17T12:38:25.808574943Z I0917 12:38:25.808504       1 backup.go:89] [2020/09/17 12:38:25.808 +00:00] [INFO] [client.go:810] ["backup streaming finish"] [StoreID=4]
2020-09-17T12:38:25.808632647Z I0917 12:38:25.808551       1 backup.go:89] [2020/09/17 12:38:25.808 +00:00] [INFO] [client.go:810] ["backup streaming finish"] [StoreID=4]
2020-09-17T12:38:25.821548004Z I0917 12:38:25.821396       1 backup.go:89] [2020/09/17 12:38:25.821 +00:00] [INFO] [client.go:817] ["range backuped"] [StartKey=74800000000000005f5f69800000000000000100] [EndKey=74800000000000005f5f698000000000000001fb]
2020-09-17T12:38:25.82230386Z I0917 12:38:25.822211       1 backup.go:89] [2020/09/17 12:38:25.822 +00:00] [INFO] [client.go:810] ["backup streaming finish"] [StoreID=5]
2020-09-17T12:38:25.822317461Z I0917 12:38:25.822226       1 backup.go:89] [2020/09/17 12:38:25.822 +00:00] [INFO] [client.go:502] ["finish backup push down"] [Ok=1]
2020-09-17T12:38:25.822332162Z I0917 12:38:25.822234       1 backup.go:89] [2020/09/17 12:38:25.822 +00:00] [INFO] [client.go:519] ["backup time range"] [StartVersion=0] [EndVersion=419521181966401538]
2020-09-17T12:38:25.822337763Z I0917 12:38:25.822239       1 backup.go:89] [2020/09/17 12:38:25.822 +00:00] [INFO] [client.go:470] ["backup range finished"] [take=54.110811ms]
2020-09-17T12:38:25.864364878Z I0917 12:38:25.864241       1 backup.go:89] [2020/09/17 12:38:25.864 +00:00] [INFO] [client.go:817] ["range backuped"] [StartKey=74800000000000005d5f720000000000000000] [EndKey=74800000000000005d5f72ffffffffffffffff00]
2020-09-17T12:38:25.865617471Z I0917 12:38:25.865388       1 backup.go:89] [2020/09/17 12:38:25.865 +00:00] [INFO] [client.go:810] ["backup streaming finish"] [StoreID=5]
2020-09-17T12:38:25.865642672Z I0917 12:38:25.865431       1 backup.go:89] [2020/09/17 12:38:25.865 +00:00] [INFO] [client.go:810] ["backup streaming finish"] [StoreID=5]
2020-09-17T12:38:25.86696387Z I0917 12:38:25.866851       1 backup.go:89] [2020/09/17 12:38:25.866 +00:00] [INFO] [client.go:817] ["range backuped"] [StartKey=7480000000000000615f720000000000000000] [EndKey=7480000000000000615f72ffffffffffffffff00]
2020-09-17T12:38:25.867885839Z I0917 12:38:25.867804       1 backup.go:89] [2020/09/17 12:38:25.867 +00:00] [INFO] [client.go:810] ["backup streaming finish"] [StoreID=4]
2020-09-17T12:38:25.86790454Z I0917 12:38:25.867821       1 backup.go:89] [2020/09/17 12:38:25.867 +00:00] [INFO] [client.go:810] ["backup streaming finish"] [StoreID=4]
2020-09-17T12:38:25.867911941Z I0917 12:38:25.867826       1 backup.go:89] [2020/09/17 12:38:25.867 +00:00] [INFO] [client.go:502] ["finish backup push down"] [Ok=1]
2020-09-17T12:38:25.867917741Z I0917 12:38:25.867834       1 backup.go:89] [2020/09/17 12:38:25.867 +00:00] [INFO] [client.go:519] ["backup time range"] [StartVersion=0] [EndVersion=419521181966401538]
2020-09-17T12:38:25.867923141Z I0917 12:38:25.867839       1 backup.go:89] [2020/09/17 12:38:25.867 +00:00] [INFO] [client.go:502] ["finish backup push down"] [Ok=1]
2020-09-17T12:38:25.867926742Z I0917 12:38:25.867850       1 backup.go:89] [2020/09/17 12:38:25.867 +00:00] [INFO] [client.go:470] ["backup range finished"] [take=99.676088ms]
2020-09-17T12:38:25.867930242Z I0917 12:38:25.867857       1 backup.go:89] [2020/09/17 12:38:25.867 +00:00] [INFO] [client.go:519] ["backup time range"] [StartVersion=0] [EndVersion=419521181966401538]
2020-09-17T12:38:25.867935442Z I0917 12:38:25.867864       1 backup.go:89] [2020/09/17 12:38:25.867 +00:00] [INFO] [client.go:470] ["backup range finished"] [take=99.752194ms]
2020-09-17T12:38:25.910685711Z I0917 12:38:25.910372       1 backup.go:89] [2020/09/17 12:38:25.910 +00:00] [INFO] [client.go:817] ["range backuped"] [StartKey=74800000000000005f5f720000000000000000] [EndKey=74800000000000005f5f72ffffffffffffffff00]
2020-09-17T12:38:25.91135136Z I0917 12:38:25.911244       1 backup.go:89] [2020/09/17 12:38:25.911 +00:00] [INFO] [client.go:810] ["backup streaming finish"] [StoreID=5]
2020-09-17T12:38:25.911365561Z I0917 12:38:25.911263       1 backup.go:89] [2020/09/17 12:38:25.911 +00:00] [INFO] [client.go:502] ["finish backup push down"] [Ok=1]
2020-09-17T12:38:25.911380562Z I0917 12:38:25.911273       1 backup.go:89] [2020/09/17 12:38:25.911 +00:00] [INFO] [client.go:519] ["backup time range"] [StartVersion=0] [EndVersion=419521181966401538]
2020-09-17T12:38:25.911402864Z I0917 12:38:25.911285       1 backup.go:89] [2020/09/17 12:38:25.911 +00:00] [INFO] [client.go:470] ["backup range finished"] [take=143.201214ms]
2020-09-17T12:38:25.911553275Z I0917 12:38:25.911403       1 backup.go:89] [2020/09/17 12:38:25.911 +00:00] [INFO] [client.go:416] ["Backup Ranges"] [take=143.265018ms]
2020-09-17T12:38:25.911822595Z I0917 12:38:25.911683       1 backup.go:89] [2020/09/17 12:38:25.911 +00:00] [INFO] [progress.go:114] [progress] [step="Full backup"] [progress=100.00%!](MISSING) [count="4 / 4"] [speed="? p/s"] [elapsed=0s] [remaining=0s]
2020-09-17T12:38:25.911837196Z I0917 12:38:25.911763       1 backup.go:89] [2020/09/17 12:38:25.911 +00:00] [INFO] [schema.go:71] ["table checksum start"] [table=`dummydb`.`some_service_properties`]
2020-09-17T12:38:25.911843397Z I0917 12:38:25.911782       1 backup.go:89] [2020/09/17 12:38:25.911 +00:00] [INFO] [schema.go:71] ["table checksum start"] [table=`dummydb`.`some`]
2020-09-17T12:38:25.911848797Z I0917 12:38:25.911799       1 backup.go:89] [2020/09/17 12:38:25.911 +00:00] [INFO] [schema.go:71] ["table checksum start"] [table=`dummydb`.`metasome`]
2020-09-17T12:38:25.914004657Z I0917 12:38:25.913756       1 backup.go:89] [2020/09/17 12:38:25.913 +00:00] [INFO] [schema.go:94] ["table checksum finished"] [table=`dummydb`.`some_service_properties`] [Crc64Xor=13627407186794931555] [TotalKvs=4] [TotalBytes=255] [take=1.834736ms]
2020-09-17T12:38:25.914421088Z I0917 12:38:25.914307       1 backup.go:89] [2020/09/17 12:38:25.914 +00:00] [INFO] [schema.go:94] ["table checksum finished"] [table=`dummydb`.`some`] [Crc64Xor=13417228213566942207] [TotalKvs=224] [TotalBytes=21181] [take=2.457682ms]
2020-09-17T12:38:25.92713793Z I0917 12:38:25.927044       1 backup.go:89] [2020/09/17 12:38:25.926 +00:00] [INFO] [schema.go:94] ["table checksum finished"] [table=`dummydb`.`metasome`] [Crc64Xor=6045785699536672715] [TotalKvs=15051] [TotalBytes=1362371] [take=15.211828ms]
2020-09-17T12:38:25.927155032Z I0917 12:38:25.927064       1 backup.go:89] [2020/09/17 12:38:25.927 +00:00] [INFO] [schema.go:107] ["backup checksum"] [take=15.342337ms]
2020-09-17T12:38:25.927374748Z I0917 12:38:25.927299       1 backup.go:89] [2020/09/17 12:38:25.927 +00:00] [INFO] [progress.go:114] [progress] [step=Checksum] [progress=100.00%!](MISSING) [count="3 / 3"] [speed="? p/s"] [elapsed=0s] [remaining=0s]
2020-09-17T12:38:25.927574063Z I0917 12:38:25.927473       1 backup.go:89] [2020/09/17 12:38:25.927 +00:00] [INFO] [client.go:917] ["fast checksum calculated"] [db=dummydb] [table=some_service_properties]
2020-09-17T12:38:25.927723174Z I0917 12:38:25.927630       1 backup.go:89] [2020/09/17 12:38:25.927 +00:00] [INFO] [client.go:917] ["fast checksum calculated"] [db=dummydb] [table=some]
2020-09-17T12:38:25.927733375Z I0917 12:38:25.927668       1 backup.go:89] [2020/09/17 12:38:25.927 +00:00] [INFO] [client.go:917] ["fast checksum calculated"] [db=dummydb] [table=metasome]
2020-09-17T12:38:25.927929689Z I0917 12:38:25.927780       1 backup.go:89] [2020/09/17 12:38:25.927 +00:00] [INFO] [client.go:863] ["fast checksum success"] [somebase=dummydb] [table=some_service_properties]
2020-09-17T12:38:25.927989994Z I0917 12:38:25.927868       1 backup.go:89] [2020/09/17 12:38:25.927 +00:00] [INFO] [client.go:863] ["fast checksum success"] [somebase=dummydb] [table=some]
2020-09-17T12:38:25.928029096Z I0917 12:38:25.927942       1 backup.go:89] [2020/09/17 12:38:25.927 +00:00] [INFO] [client.go:863] ["fast checksum success"] [somebase=dummydb] [table=metasome]
2020-09-17T12:38:25.928036597Z I0917 12:38:25.927969       1 backup.go:89] [2020/09/17 12:38:25.927 +00:00] [INFO] [client.go:196] ["save backup meta"] [path=s3://tidb-backup/tidb-cluster-pd.namespace-2379-2020-09-17t12-38-00] [size=8226]
2020-09-17T12:38:25.95357559Z I0917 12:38:25.953416       1 backup.go:89] [2020/09/17 12:38:25.953 +00:00] [INFO] [ddl.go:384] ["[ddl] DDL closed"] [ID=67c516bd-f53f-4748-93e4-bee3277c0605] ["take time"=4.064901ms]
2020-09-17T12:38:25.953604592Z I0917 12:38:25.953445       1 backup.go:89] [2020/09/17 12:38:25.953 +00:00] [INFO] [ddl.go:297] ["[ddl] stop DDL"] [ID=67c516bd-f53f-4748-93e4-bee3277c0605]
2020-09-17T12:38:25.960072571Z I0917 12:38:25.959913       1 backup.go:89] [2020/09/17 12:38:25.959 +00:00] [INFO] [domain.go:442] ["infoSyncerKeeper exited."]
2020-09-17T12:38:25.960155178Z I0917 12:38:25.960029       1 backup.go:89] [2020/09/17 12:38:25.959 +00:00] [INFO] [domain.go:612] ["domain closed"] ["take time"=10.7866ms]
2020-09-17T12:38:25.960583409Z I0917 12:38:25.960360       1 backup.go:89] [2020/09/17 12:38:25.960 +00:00] [INFO] [collector.go:208] ["Full backup Success summary: total backup ranges: 4, total success: 4, total failed: 0, total take(s): 0.14, total kv: 30558, total size(MB): 2.64, avg speed(MB/s): 18.42"] ["backup checksum"=15.354838ms] ["backup fast checksum"=595.844µs] ["backup total regions"=4] [BackupTS=419521181966401538] [Size=250643]
2020-09-17T12:38:25.962692266Z I0917 12:38:25.962420       1 backup.go:89] 
2020-09-17T12:38:25.962704267Z I0917 12:38:25.962504       1 backup.go:104] Backup some for cluster namespace/tidb-schedule-backup-minio-2020-09-17t12-38-00 successfully
2020-09-17T12:38:25.984045948Z I0917 12:38:25.983916       1 manager.go:261] reset cluster namespace/tidb-schedule-backup-minio-2020-09-17t12-38-00 tikv_gc_life_time to 10m0s success
2020-09-17T12:38:25.98406785Z I0917 12:38:25.983938       1 manager.go:276] backup cluster namespace/tidb-schedule-backup-minio-2020-09-17t12-38-00 some to s3://tidb-backup/tidb-cluster-pd.namespace-2379-2020-09-17t12-38-00/ success
2020-09-17T12:38:25.994618032Z I0917 12:38:25.994496       1 manager.go:293] Get size 250721 for backup files in s3://tidb-backup/tidb-cluster-pd.namespace-2379-2020-09-17t12-38-00/ of cluster namespace/tidb-schedule-backup-minio-2020-09-17t12-38-00 success
2020-09-17T12:38:26.010631219Z I0917 12:38:26.010447       1 manager.go:308] get cluster namespace/tidb-schedule-backup-minio-2020-09-17t12-38-00 commitTs 419521181966401538 success
2020-09-17T12:38:26.039188435Z I0917 12:38:26.039014       1 backup_status_updater.go:64] Backup: [namespace/tidb-schedule-backup-minio-2020-09-17t12-38-00] updated successfully

There isn't any reference about retention operations.

No backups were deleted in minio storage. Currently, I have 20 backups in the minio bucket.

My TiDB version is v4.0.4

Thank you

Regards

sergiomcalzada commented 3 years ago

Hi, I have the same setup and the same problem. The TiDbBackups are deleted from the cluster but the files generated in the storage are not deleted so, in the end, they will hit the space limits or grow indefinitely.

Any plan to let the BackupScheduler delete old backup generated files in the storage?

roshanjonah commented 2 years ago

I am having the same problem as well. Any updates on this?

sergiomcalzada commented 2 years ago

I think this is not properly explained in the docs. We must set a cleanPolicy to Delete. After setting this value files are being deleted

https://docs.pingcap.com/tidb-in-kubernetes/stable/backup-restore-overview#backup-and-restore-process

To make a backup of the TiDB cluster in Kubernetes, you need to create a [Backup CR](https://docs.pingcap.com/tidb-in-kubernetes/stable/backup-restore-cr#backup-cr-fields) object to describe the backup or create **a BackupSchedule CR object** to describe a scheduled backup.

https://docs.pingcap.com/tidb-in-kubernetes/stable/backup-restore-cr#backupschedule-cr-fields

The backupSchedule configuration consists of two parts. One is backupTemplate, and the other is the unique configuration of backupSchedule.

backupTemplate specifies the configuration related to the cluster and remote storage, which is the same as the spec configuration of **[the Backup CR](https://docs.pingcap.com/tidb-in-kubernetes/stable/backup-restore-cr#backup-cr-fields)**.

https://docs.pingcap.com/tidb-in-kubernetes/stable/backup-restore-cr#backup-cr-fields

.spec.cleanPolicy: The cleaning policy for the backup data when the backup CR is deleted. You can choose one from the following three clean policies:

Retain: under any circumstances, retain the backup data when deleting the backup CR.

Delete: under any circumstances, delete the backup data when deleting the backup CR.

OnFailure: if the backup fails, delete the backup data when deleting the backup CR.

If this field is not configured, or if you configure a value other than the three policies above, the backup data is retained.

Note that in v1.1.2 and earlier versions, this field does not exist. The backup data is deleted along with the CR by default. For v1.1.3 or later versions, if you want to keep this earlier behavior, set this field to Delete.
roshanjonah commented 2 years ago

@sergiomcalzada I am not sure if I have done it correctly. I added cleanPolicy and set it to delete under BKS template. Here is the describe for BKS

$ k describe bks/tidb-backup-schedule-s3 -n tidb-admin
Name:         tidb-backup-schedule-s3
Namespace:    tidb-admin
Labels:       <none>
Annotations:  <none>
API Version:  pingcap.com/v1alpha1
Kind:         BackupSchedule
Metadata:
  Creation Timestamp:  2022-04-29T10:11:33Z
  Generation:          7
  Managed Fields:
    API Version:  pingcap.com/v1alpha1
    Fields Type:  FieldsV1
    fieldsV1:
      f:metadata:
        f:annotations:
          .:
          f:kubectl.kubernetes.io/last-applied-configuration:
      f:spec:
        .:
        f:backupTemplate:
          .:
          f:backupType:
          f:br:
            .:
            f:cluster:
            f:clusterNamespace:
          f:cleanPolicy:
          f:s3:
            .:
            f:bucket:
            f:endpoint:
            f:provider:
            f:secretName:
        f:maxReservedTime:
        f:schedule:
    Manager:      kubectl-client-side-apply
    Operation:    Update
    Time:         2022-04-29T10:11:33Z
    API Version:  pingcap.com/v1alpha1
    Fields Type:  FieldsV1
    fieldsV1:
      f:spec:
        f:backupTemplate:
          f:resources:
      f:status:
        .:
        f:lastBackup:
        f:lastBackupTime:
    Manager:         tidb-controller-manager
    Operation:       Update
    Time:            2022-04-29T12:00:26Z
  Resource Version:  54575871
  UID:               8680029d-a8a5-487a-b2bb...
Spec:
  Backup Template:
    Backup Type:  full
    Br:
      Cluster:            advanced-tidb
      Cluster Namespace:  tidb-cluster
    Clean Policy:         delete
    Resources:
    s3:
      Bucket:         tidb...
      Endpoint:       https://nyc3.digitaloceanspaces.com
      Provider:       s3
      Secret Name:    s3-secret
  Max Reserved Time:  24h
  Schedule:           0 */12 * * *
Status:
  Last Backup:       tidb-backup-schedule-s3-2022-05-02t00-00-00
  Last Backup Time:  2022-05-02T00:00:00Z
Events:              <none>

My spec file looks like this:

---
apiVersion: pingcap.com/v1alpha1
kind: BackupSchedule
metadata:
  name: tidb-backup-schedule-s3
  namespace: tidb-admin
spec:
  #maxBackups: 5
  #pause: true
  maxReservedTime: "24h"
  schedule: "0 */12 * * *"
  backupTemplate:
    cleanPolicy: delete
    backupType: full
    br:
      cluster: advanced-tidb
      clusterNamespace: tidb-cluster
    s3:
      provider: s3
      secretName: s3-secret
      endpoint: https://nyc3.digitaloceanspaces.com
      bucket: tidb...

My maxReservedTime: "24h" but I still see backups that are two days old with files in them

Screen Shot 2022-05-02 at 9 14 15 PM
BornChanger commented 10 months ago

It's a tidb operator issue and you should open at repo https://github.com/pingcap/tidb-operator. And btw, you can check if the problem is gone with tidb operator release v1.5.1.

roshanjonah commented 10 months ago

We can close this now. We don't use TiDB any longer.