コード例 #1
0
        public static void DelelteBackups()
        {
            DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.Create();

            //delete backup contains "a"
            var dataTime          = DateTime.UtcNow.AddDays(1).ToString("yyyy-MM-dd");
            var listBackupRequest = new ListBackupsRequest
            {
                Parent = InstanceName.Format(projectId, instanceId),
                Filter = $"create_time < {dataTime}"
            };

            var backups = databaseAdminClient.ListBackups(listBackupRequest);

            foreach (var backup in backups)
            {
                var deleteBackupRequest = new DeleteBackupRequest()
                {
                    Name = backup.Name
                };
                databaseAdminClient.DeleteBackup(deleteBackupRequest);
            }
        }