Constructor
new Backup(cluster, name)
Parameters:
Name | Type | Description |
---|---|---|
cluster |
Cluster |
The parent instance of this backup. |
name |
string |
Name of the backup. |
Members
endDate
A Date-compatible PreciseDate representing the time that the backup was finished.
expireDate
A Date-compatible PreciseDate representing the expiration time of this backup.
startDate
A Date-compatible PreciseDate representing the time that this backup was started.
Methods
create(config, callbackopt) → {void|Promise.<CreateBackupResponse>}
Starts creating a new Cloud Bigtable Backup.
The returned long-running operation can be used to track creation of the backup. Cancelling the returned operation will stop the creation and delete the backup.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
config |
CreateBackupConfig |
Configuration object. Properties
|
|||||||||||||||||||||
callback |
CreateBackupCallback |
<optional> |
The callback function. Properties
|
Returns:
Type | Description |
---|---|
void | Promise.<CreateBackupResponse> |
Example
const {Bigtable} = require('@google-cloud/bigtable');
const bigtable = new Bigtable();
async function createBackup() {
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
// const instanceId = 'YOUR_INSTANCE_ID';
// const tableId = 'YOUR_TABLE_ID';
// const clusterId = 'YOUR_CLUSTER_ID';
// const backupId = 'YOUR_BACKUP_ID';
const instance = bigtable.instance(instanceId);
const cluster = instance.cluster(clusterId);
const [backup, operation] = await cluster.createBackup(backupId, {
table: tableId,
expireTime: new Date(Date.now() + 7 * 60 * 60 * 1000), // 7 hours from now
});
console.log('Started a table backup operation.');
await operation.promise();
console.log(`Backup "${backup.id}" is now ready for use.`);
}
await createBackup();
delete(gaxOptionsOrCallbackopt, callbackopt) → {void|Promise.<DeleteBackupResponse>}
Deletes this pending or completed Cloud Bigtable backup.
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
gaxOptionsOrCallback |
CallOptions | DeleteBackupCallback |
<optional> |
|||||||||||||
callback |
DeleteBackupCallback |
<optional> |
The callback function. Properties
|
Returns:
Type | Description |
---|---|
void | Promise.<DeleteBackupResponse> |
Example
const {Bigtable} = require('@google-cloud/bigtable');
const bigtable = new Bigtable();
async function deleteBackup() {
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
// const instanceId = 'YOUR_INSTANCE_ID';
// const tableId = 'YOUR_TABLE_ID';
// const clusterId = 'YOUR_CLUSTER_ID';
// const backupId = 'YOUR_BACKUP_ID';
const instance = bigtable.instance(instanceId);
const table = instance.table(tableId);
const cluster = table.cluster(clusterId);
const backup = cluster.backup(backupId);
await backup.delete();
console.log(`Backup ${backupId} was deleted successfully.`);
}
await deleteBackup();
exists(gaxOptionsopt, callback)
Check if a backup exists.
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
gaxOptions |
object |
<optional> |
Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/CallSettings.html. |
||||||||||||
callback |
function |
The callback function. Properties
|
get(gaxOptionsopt, callback)
Get a backup if it exists.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
gaxOptions |
object |
<optional> |
Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/CallSettings.html. |
||||||||||||||||
callback |
function |
The callback function. Properties
|
Example
const {Bigtable} = require('@google-cloud/bigtable');
const bigtable = new Bigtable();
async function getBackup() {
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
// const instanceId = 'YOUR_INSTANCE_ID';
// const tableId = 'YOUR_TABLE_ID';
// const clusterId = 'YOUR_CLUSTER_ID';
// const backupId = 'YOUR_BACKUP_ID';
const instance = bigtable.instance(instanceId);
const table = instance.table(tableId);
const cluster = table.cluster(clusterId);
// Create a reference to the backup before performing operations on it.
const backup = cluster.backup(backupId);
// Get the backup's metadata, with information such as when it will expire
// and how big it is.
const [metadata] = await backup.getMetadata();
console.log(`The backup is ${metadata.sizeBytes} bytes.`);
// Time properties have Date helpers to convert to a `PreciseDate`.
console.log(
`The backup will auto-delete at ${metadata.expireDate.toISOString()}`
);
console.log(
`The backup finished being created at ${metadata.endTime.toISOString()}`
);
}
await getBackup();
getIamPolicy(optionsopt, cbopt, policy)
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
<optional> |
Configuration object. Properties
|
||||||||||||
cb |
function |
<optional> |
The callback function. |
||||||||||||
callback.error |
error |
<nullable> |
An error returned while making this request. |
||||||||||||
policy |
Policy |
The policy. |
Example
const {Bigtable} = require('@google-cloud/bigtable');
const bigtable = new Bigtable();
const instance = bigtable.instance(instanceId);
const table = instance.table(tableId);
table
.getIamPolicy()
.then(result => {
const policy = result[0];
})
.catch(err => {
// Handle the error.
});
getMetadata(gaxOptionsopt, callback)
Get a backup if it exists.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
gaxOptions |
object |
<optional> |
Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/CallSettings.html. |
||||||||||||||||
callback |
function |
The callback function. Properties
|
Example
const {Bigtable} = require('@google-cloud/bigtable');
const bigtable = new Bigtable();
async function getBackup() {
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
// const instanceId = 'YOUR_INSTANCE_ID';
// const tableId = 'YOUR_TABLE_ID';
// const clusterId = 'YOUR_CLUSTER_ID';
// const backupId = 'YOUR_BACKUP_ID';
const instance = bigtable.instance(instanceId);
const table = instance.table(tableId);
const cluster = table.cluster(clusterId);
// Create a reference to the backup before performing operations on it.
const backup = cluster.backup(backupId);
// Get the backup's metadata, with information such as when it will expire
// and how big it is.
const [metadata] = await backup.getMetadata();
console.log(`The backup is ${metadata.sizeBytes} bytes.`);
// Time properties have Date helpers to convert to a `PreciseDate`.
console.log(
`The backup will auto-delete at ${metadata.expireDate.toISOString()}`
);
console.log(
`The backup finished being created at ${metadata.endTime.toISOString()}`
);
}
await getBackup();
restore(tableId, gaxOptionsOrCallbackopt, callbackopt) → {void|Promise.<RestoreTableResponse>}
Create a new table by restoring from this completed backup.
The new table must be in the same instance as the instance containing the backup. The returned long-running operation can be used to track the progress of the operation, and to cancel it.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
tableId |
string |
The id of the table to create and restore to. This table must not already exist. |
|||||||||||||||||||||
gaxOptionsOrCallback |
CallOptions | RestoreTableCallback |
<optional> |
|||||||||||||||||||||
callback |
RestoreTableCallback |
<optional> |
The callback function. Properties
|
Returns:
Type | Description |
---|---|
void | Promise.<RestoreTableResponse> |
setIamPolicy(gaxOptionsopt, callbackopt, policy)
Parameters:
Name | Type | Attributes | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
gaxOptions |
object |
<optional> |
Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/CallSettings.html. |
||||||||
callback |
function |
<optional> |
The callback function. Properties
|
||||||||
policy |
Policy |
The policy. |
Example
const {Bigtable} = require('@google-cloud/bigtable');
const bigtable = new Bigtable();
const instance = bigtable.instance(instanceId);
const policy = {
bindings: [
{
role: 'roles/bigtable.viewer',
members: ['user:mike@example.com', 'group:admins@example.com'],
},
],
};
instance
.setIamPolicy(policy)
.then(result => {
const setPolicy = result[0];
})
.catch(err => {
// Handle the error
});
setMetadata(metadata, gaxOptionsOrCallbackopt, callbackopt) → {void|Promise.<BackupSetMetadataResponse>}
Updates this pending or completed Cloud Bigtable Backup.
Parameters:
Name | Type | Attributes | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
metadata |
ModifiableBackupFields |
The fields to be updated. |
|||||||||
gaxOptionsOrCallback |
CallOptions | BackupSetMetadataCallback |
<optional> |
|||||||||
callback |
BackupSetMetadataCallback |
<optional> |
The callback function. Properties
|
||||||||
|
|||||||||||
callback.apiResponse |
object |
The full API response. |
Returns:
Type | Description |
---|---|
void | Promise.<BackupSetMetadataResponse> |
Example
const {Bigtable} = require('@google-cloud/bigtable');
const bigtable = new Bigtable();
async function updateBackup() {
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
// const instanceId = 'YOUR_INSTANCE_ID';
// const tableId = 'YOUR_TABLE_ID';
// const clusterId = 'YOUR_CLUSTER_ID';
// const backupId = 'YOUR_BACKUP_ID';
const instance = bigtable.instance(instanceId);
const table = instance.table(tableId);
const cluster = table.cluster(clusterId);
const backup = cluster.backup(backupId);
// Extend a backup's life by updating its expiry date.
const [metadata] = await backup.setMetadata({
expireTime: new Date(Date.now() + 24 * 60 * 60 * 1000), // 24 hours
});
console.log(`The backup will now auto-delete at ${metadata.expireDate}.`);
}
await updateBackup();
testIamPermissions(permissions, gaxOptionsopt, callbackopt, permissions)
Parameters:
Name | Type | Attributes | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
permissions |
string | Array.<string> |
The permission(s) to test for. |
|||||||||
gaxOptions |
object |
<optional> |
Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/CallSettings.html. |
||||||||
callback |
function |
<optional> |
The callback function. Properties
|
||||||||
permissions |
Array.<string> |
A subset of permissions that the caller is allowed. |
Example
const {Bigtable} = require('@google-cloud/bigtable');
const bigtable = new Bigtable();
const instance = bigtable.instance(instanceId);
const table = instance.table(tableId);
const permissions = ['bigtable.tables.get', 'bigtable.tables.readRows'];
table
.testIamPermissions(permissions)
.then(result => {
const grantedPermissions = result[0];
})
.catch(err => {
// Handle the error
});