-
Notifications
You must be signed in to change notification settings - Fork 477
Restructured DR backup section for clarity and thoroughness #20873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| You will encounter an error if you run multiple [backup collections]({% link {{ page.version.version }}/take-full-and-incremental-backups.md %}#backup-collections) to the same storage URI. Each collection's URI must be unique. | ||
| You will encounter an error if you run multiple [backup collections]({% link {{ page.version.version }}/take-full-and-incremental-backups.md %}#backup-collections) to the same storage URI. Backup collections can contain multiple full and incremental backups, but each collection's URI must be unique. If you are using backup schedules, each schedule must have a unique URI. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,45 +114,182 @@ sql_txn_commit_count{tenant="demo"} 0 | |
|
|
||
| When connected to a virtual cluster from the DB Console, metrics which measure SQL and related activity show data scoped to the virtual cluster. All other metrics are collected system-wide and display the same data on all virtual clusters including the system virtual cluster. | ||
|
|
||
| ## Disaster recovery | ||
| ## Backup and restore | ||
|
|
||
| When cluster virtualization is enabled, [backup]({% link {{ page.version.version }}/backup.md %}) and [restore]({% link {{ page.version.version }}/restore.md %}) commands are scoped to the virtual cluster by default. | ||
| Cockroach Labs recommends that you regularly [back up]({% link {{ page.version.version }}/take-full-and-incremental-backups.md %}#full-backups) your data. When using virtual clusters, perform backups on the _application virtual cluster (app VC)_. Only the app VC's data and settings are included in these backups, and data and settings for other virtual clusters or for the _system virtual cluster (system VC)_ are omitted. | ||
|
|
||
| ### Back up a virtual cluster | ||
| ### Create a backup schedule for your app VC | ||
|
|
||
| To back up a virtual cluster: | ||
| Cockroach Labs recommends using [backup schedules]({% link {{ page.version.version }}/create-schedule-for-backup.md %}) to automate full and incremental backups of your data. | ||
|
|
||
| 1. [Connect to the virtual cluster](#connect-to-a-virtual-cluster) you want to back up as a user with the `admin` role on the virtual cluster. | ||
| 1. [Back up the cluster]({% link {{ page.version.version }}/backup.md %}). Only the virtual cluster's data and settings are included in the backup, and data and settings for other virtual clusters or for the system virtual cluster is omitted. | ||
| Use the following process to create a schedule for a cluster-level backup of your app VC. In this example, the schedule takes revision history for the backup every day at midnight. | ||
|
|
||
| For details about restoring a backup of a virtual cluster, refer to [Restore a virtual cluster](#restore-a-virtual-cluster). | ||
| 1. [Connect](#connect-to-a-virtual-cluster) to the app VC as a user with [supported privileges]({% link {{ page.version.version }}/security-reference/authorization.md %}#supported-privileges) on the app VC. In this example the user has the `BACKUP` privilege. | ||
|
|
||
| ### Back up the entire cluster | ||
| {% include_cached copy-clipboard.html %} | ||
| ~~~ shell | ||
| cockroach sql --url \ | ||
| "postgresql://root@{primary node IP or hostname}:26257?options=-ccluster={app_virtual_cluster_name}&sslmode=verify-full" \ | ||
| --certs-dir "certs" | ||
| ~~~ | ||
|
|
||
| To back up the entire CockroachDB cluster, including all virtual clusters and the system virtual cluster: | ||
| 1. [Create a backup schedule]({% link {{ page.version.version }}/create-schedule-for-backup.md %}#create-a-scheduled-backup-for-a-cluster): | ||
|
|
||
| 1. [Connect to the system virtual cluster](#connect-to-the-system-virtual-cluster) as a user with the `admin` role on the system virtual cluster. | ||
| 1. [Back up the cluster]({% link {{ page.version.version }}/backup.md %}), and include the `INCLUDE_ALL_SECONDARY_TENANTS` flag in the `BACKUP` command. All virtual clusters and the system virtual cluster are included in the backup. | ||
| {% include_cached copy-clipboard.html %} | ||
| ~~~ sql | ||
| CREATE SCHEDULE schedule_label | ||
| FOR BACKUP INTO 's3://test/backups/schedule_test?AWS_ACCESS_KEY_ID=x&AWS_SECRET_ACCESS_KEY=x' | ||
| WITH revision_history | ||
| RECURRING '@daily'; | ||
| ~~~ | ||
|
|
||
| ### Restore a virtual cluster | ||
| ~~~ | ||
| schedule_id | name | status | first_run | schedule | backup_stmt | ||
| ---------------------+----------------+------------------------------------------------+----------------------------------+----------+--------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
| 588796190000218113 | schedule_label | PAUSED: Waiting for initial backup to complete | NULL | @daily | BACKUP INTO LATEST IN 's3://test/schedule-test?AWS_ACCESS_KEY_ID=x&AWS_SECRET_ACCESS_KEY=x' WITH revision_history, detached | ||
| 588796190012702721 | schedule_label | ACTIVE | 2020-09-10 16:52:17.280821+00:00 | @weekly | BACKUP INTO 's3://test/schedule-test?AWS_ACCESS_KEY_ID=x&AWS_SECRET_ACCESS_KEY=x' WITH revision_history, detached | ||
| (2 rows) | ||
| ~~~ | ||
|
|
||
| {% include {{ page.version.version }}/backups/backup-storage-collision.md %} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @msbutler I feel like I barely understand this directive. It reads to me like we don't want to take multiple full backups to the same place. Any ideas on how we could maek this clearer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, there could be a sentence explaining the backup collision problem: "each backup schedule should have a unique URI to avoid two backup schedules colliding in the same URI", or something |
||
|
|
||
| For information on scheduling backups at different levels or with other options, consult [CREATE SCHEDULE FOR BACKUP]({% link {{ page.version.version }}/create-schedule-for-backup.md %}). | ||
|
|
||
| ### Back up your app VC | ||
|
|
||
| Use the following process to take a one-off full backup of your app VC. | ||
|
|
||
| 1. [Connect](#connect-to-a-virtual-cluster) to the app VC as a user with [supported privileges]({% link {{ page.version.version }}/security-reference/authorization.md %}#supported-privileges) on the app VC. In this example the user has the `BACKUP` privilege. | ||
|
|
||
| {% include_cached copy-clipboard.html %} | ||
| ~~~ shell | ||
| cockroach sql --url \ | ||
| "postgresql://root@{primary node IP or hostname}:26257?options=-ccluster={app_virtual_cluster_name}&sslmode=verify-full" \ | ||
| --certs-dir "certs" | ||
| ~~~ | ||
|
|
||
| 1. [Perform a full backup]({% link {{ page.version.version }}/backup.md %}#back-up-a-cluster): | ||
|
|
||
| {% include_cached copy-clipboard.html %} | ||
| ~~~ sql | ||
| BACKUP INTO 'external://backup_s3/app' AS OF SYSTEM TIME '-10s'; | ||
| ~~~ | ||
|
|
||
| ### Back up a database from your app VC | ||
|
|
||
| Use the following process to take a one-off database-level backup on your app VC. | ||
|
|
||
| 1. [Connect](#connect-to-a-virtual-cluster) to the app VC as a user with [supported privileges]({% link {{ page.version.version }}/security-reference/authorization.md %}#supported-privileges) on the app VC. In this example the user has the `BACKUP` privilege. | ||
|
|
||
| {% include_cached copy-clipboard.html %} | ||
| ~~~ shell | ||
| cockroach sql --url \ | ||
| "postgresql://root@{primary node IP or hostname}:26257?options=-ccluster={app_virtual_cluster_name}&sslmode=verify-full" \ | ||
| --certs-dir "certs" | ||
| ~~~ | ||
|
|
||
| 1. [Back up]({% link {{ page.version.version }}/backup.md %}#back-up-a-database) a single database: | ||
|
|
||
| {% include_cached copy-clipboard.html %} | ||
| ~~~ sql | ||
| BACKUP DATABASE bank INTO 'external://backup_s3/app/db' AS OF SYSTEM TIME '-10s'; | ||
| ~~~ | ||
|
|
||
| Or back up multiple databases: | ||
|
|
||
| {% include_cached copy-clipboard.html %} | ||
| ~~~ sql | ||
| BACKUP DATABASE bank, employees INTO 'external://backup_s3/app/db' AS OF SYSTEM TIME '-10s'; | ||
| ~~~ | ||
|
|
||
| ### Back up a table or view from your app VC | ||
|
|
||
| Use the following procecss to take a one-off table-level or view-level backup on your app VC. | ||
|
|
||
| You can restore a backup of a virtual cluster to: | ||
| 1. [Connect](#connect-to-a-virtual-cluster) to the app VC as a user with [supported privileges]({% link {{ page.version.version }}/security-reference/authorization.md %}#supported-privileges) on the app VC. In this example the user has the `BACKUP` privilege. | ||
|
|
||
| - The original virtual cluster on the original CockroachDB cluster. | ||
| - A different virtual cluster on the original CockroachDB cluster. | ||
| - A different virtual cluster on a different CockroachDB cluster with cluster virtualization enabled. | ||
| {% include_cached copy-clipboard.html %} | ||
| ~~~ shell | ||
| cockroach sql --url \ | ||
| "postgresql://root@{primary node IP or hostname}:26257?options=-ccluster={app_virtual_cluster_name}&sslmode=verify-full" \ | ||
| --certs-dir "certs" | ||
| ~~~ | ||
|
|
||
| 1. [Back up]({% link {{ page.version.version }}/backup.md %}#back-up-a-table-or-view) a single table or view: | ||
|
|
||
| {% include_cached copy-clipboard.html %} | ||
| ~~~ sql | ||
| BACKUP bank.customers INTO 'external://backup_s3/app/table' AS OF SYSTEM TIME '-10s'; | ||
| ~~~ | ||
|
|
||
| Or back up multiple tables: | ||
|
|
||
| {% include_cached copy-clipboard.html %} | ||
| ~~~ sql | ||
| BACKUP bank.customers, bank.accounts INTO 'external://backup_s3/app/table' AS OF SYSTEM TIME '-10s'; | ||
| ~~~ | ||
|
|
||
| ### Back up a schema from your app VC | ||
|
|
||
| Use the following procecss to take a one-off schema-level backup on your app VC using a wildcard (`*`). | ||
|
|
||
| 1. [Connect](#connect-to-a-virtual-cluster) to the app VC as a user with [supported privileges]({% link {{ page.version.version }}/security-reference/authorization.md %}#supported-privileges) on the app VC. In this example the user has the `BACKUP` privilege. | ||
|
|
||
| {% include_cached copy-clipboard.html %} | ||
| ~~~ shell | ||
| cockroach sql --url \ | ||
| "postgresql://root@{primary node IP or hostname}:26257?options=-ccluster={app_virtual_cluster_name}&sslmode=verify-full" \ | ||
| --certs-dir "certs" | ||
| ~~~ | ||
|
|
||
| 1. [Back up]({% link {{ page.version.version }}/backup.md %}#back-up-all-tables-in-a-schema) all tables in a schema: | ||
|
|
||
| {% include_cached copy-clipboard.html %} | ||
| ~~~ sql | ||
| BACKUP test_schema.* INTO 'external://backup_s3/app/schema' AS OF SYSTEM TIME '-10s'; | ||
| ~~~ | ||
|
|
||
| ### Back up your system VC | ||
|
|
||
| You can also back up your system VC to preserve metadata such as users and cluster settings. Use the following process to back up your system VC. | ||
|
|
||
| 1. [Connect](#connect-to-the-system-virtual-cluster) to the system VC as a user with [supported privileges]({% link {{ page.version.version }}/security-reference/authorization.md %}#supported-privileges) on the system VC. In this example the user has the `BACKUP` privilege. | ||
|
|
||
| {% include_cached copy-clipboard.html %} | ||
| ~~~ shell | ||
| cockroach sql --url \ | ||
| "postgresql://root@{primary node IP or hostname}:26257?options=-ccluster=system&sslmode=verify-full" \ | ||
| --certs-dir "certs" | ||
| ~~~ | ||
|
|
||
| 1. [Perform a full backup]({% link {{ page.version.version }}/backup.md %}#back-up-a-cluster): | ||
|
|
||
| {% include_cached copy-clipboard.html %} | ||
| ~~~ sql | ||
| BACKUP INTO 'external://backup_s3/system' AS OF SYSTEM TIME '-10s'; | ||
| ~~~ | ||
|
|
||
| {% include {{ page.version.version }}/backups/backup-storage-collision.md %} | ||
|
|
||
| ### Restore a virtual cluster | ||
|
|
||
| To restore only a virtual cluster: | ||
| If needed, you can restore backups to a new app VC with no user-created databases or tables. To restore your app VC from the latest full backup: | ||
|
|
||
| 1. [Connect to the destination virtual cluster](#connect-to-a-virtual-cluster) as a user with the `admin` role on the virtual cluster. | ||
| 1. [Restore the cluster]({% link {{ page.version.version }}/restore.md %}). Only the virtual cluster's data and settings are restored. | ||
| 1. [Connect to the destination app VC](#connect-to-a-virtual-cluster) as a user with [supported privileges]({% link {{ page.version.version }}/security-reference/authorization.md %}#supported-privileges) on the system VC. In this example the user has the `RESTORE` privilege. | ||
|
|
||
| ### Restore the entire cluster | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the section above can also be deleted. it applies to tenant level backups. |
||
| {% include_cached copy-clipboard.html %} | ||
| ~~~ shell | ||
| cockroach sql --url \ | ||
| "postgresql://root@{primary node IP or hostname}:26257?options=-ccluster={app_virtual_cluster_name}&sslmode=verify-full" \ | ||
| --certs-dir "certs" | ||
| ~~~ | ||
|
|
||
| To restore the entire CockroachDB cluster, including all virtual clusters and the system virtual cluster: | ||
| 1. [Restore the cluster]({% link {{ page.version.version }}/restore.md %}): | ||
|
|
||
| 1. [Connect to the destination system virtual cluster](#connect-to-the-system-virtual-cluster) as a user with the `admin` role on the system virtual cluster. | ||
| 1. [Restore the cluster]({% link {{ page.version.version }}/restore.md %}) from a backup that included the the `INCLUDE_ALL_SECONDARY_VIRTUAL_CLUSTERS` flag. All virtual clusters and the system virtual cluster are restored. | ||
| {% include_cached copy-clipboard.html %} | ||
| ~~~ sql | ||
| RESTORE FROM LATEST IN 's3://bucket/path?AUTH=implicit'; | ||
| ~~~ | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we could be a bit more explicit on how to restore one of these backups: connect to a virtual cluster, and run restore like you normally would (for example, if the VC is empty and you took a cluster level backup, you can do a cluster level restore). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agree, we should have an example and code snippet
I don't think we should use this example though. We're not telling users to use cluster level backups. We should just add some examples about restoring an app VC to the same CRDB cluster and to a different CRDB cluster. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
why not? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. whatttttt? i thought you said not to!! Like i thought everythihng should be done per-VC. Otherwise we can't do table or DB level restores from a full cluster backup There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think you might be conflating cluster level backups and virtual cluster (or tenant) level backups (another reason i can't with the virtual cluster terminology).
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's be more specific: by cluster level I mean taking a backup of the whole physical cluster. If we're talking about app vc level, then we should say 'vc level.' My point was that we should not document your second bullet, where we take a app vc backup from the system vc, AND we should also not document 'taking a backup of their entire cluster' which would be a 'cluster level backup.' I'm referring to the 'include secondary clusters' option when you take a backup |
||
| ## Configure cluster settings | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, why was this removed? I wonder if we should say "Backups when cluster virtualization is enabled" or something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kind of merged this section into the other because it seemed like they were about different parts of the same process, and it felt to me like the break wasn't really needed. I'm reworking things to make the distinction between "cluster" and "virtual cluster" more obvious so this may change