Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

Commit

Permalink
backup: Use GCS backup in Kubernetes example.
Browse files Browse the repository at this point in the history
  • Loading branch information
enisoc committed Oct 21, 2015
1 parent 8cc50a3 commit c976134
Show file tree
Hide file tree
Showing 12 changed files with 346 additions and 158 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@ _test/
# php downloaded dependencies
/php/composer.phar
/php/vendor

# site-local example files
/examples/kubernetes/config.sh

57 changes: 42 additions & 15 deletions doc/BackupAndRestore.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,16 @@ Vitess. Vitess uses backups for two purposes:
## Prerequisites

Vitess stores data backups on a Backup Storage service. Currently,
Vitess only supports backups to an NFS directory and can use any
network-mounted drive as the backup repository. The core Vitess software's
[interface.go](https://github.com/youtube/vitess/blob/master/go/vt/mysqlctl/backupstorage/interface.go)
file defines an interface for the Backup Storage service. The interface
defines methods for creating, listing, and removing backups.
Vitess supports backups to either [Google Cloud Storage](https://cloud.google.com/storage/)
or any network-mounted drive (such as NFS). The core Vitess software's
[BackupStorage interface](https://github.com/youtube/vitess/blob/master/go/vt/mysqlctl/backupstorage/interface.go)
defines methods for creating, listing, and removing backups. Plugins for other
storage services just need to implement the interface.

Before you can back up or restore a tablet, you need to ensure that the
tablet is aware of the Backup Storage system that you are using. To do so,
use the following command-line flags when starting a vttablet that has
access to a local file system where you are storing backups. In practice,
you should always use these flags when starting a tablet that has access
to backups on a local file system.
access to the location where you are storing backups.

<table class="responsive">
<thead>
Expand All @@ -28,20 +26,48 @@ to backups on a local file system.
</thead>
<tbody>
<tr>
<td><nobr><code>--backup_storage_implementation</code></nobr></td>
<td>Specifies the implementation of the Backup Storage interface to use.<br><br>If you run Vitess on a machine that has access to an NFS directory where you store backups, set the flag's value to file. Otherwise, do not set this flag or either of the other remaining flags.</td>
<td><nobr><code>-backup_storage_implementation</code></nobr></td>
<td>Specifies the implementation of the Backup Storage interface to use.<br><br>
Current plugin options available are:
<ul>
<li><code>gcs</code>: For Google Cloud Storage.</li>
<li><code>file</code>: For NFS or any other filesystem-mounted network drive.</li>
</ul>
</td>
</tr>
<tr>
<td><nobr><code>--file_backup_storage_root</code></nobr></td>
<td>Identifies the root directory for backups. Set this flag if the backup_storage_implementation flag is set to file.</td>
<td><nobr><code>-file_backup_storage_root</code></nobr></td>
<td>For the <code>file</code> plugin, this identifies the root directory for backups.</td>
</tr>
<tr>
<td><nobr><code>--restore_from_backup</code></nobr></td>
<td>Indicates that, when started, the tablet should restore the most recent backup from the file_backup_storage_root directory. This flag is only relevant if the other two flags listed above are also set.</td>
<td><nobr><code>-gcs_backup_storage_project</code></nobr></td>
<td>For the <code>gcs</code> plugin, this identifies the <a href="https://cloud.google.com/storage/docs/projects">project</a> to use.</td>
</tr>
<tr>
<td><nobr><code>-gcs_backup_storage_bucket</code></nobr></td>
<td>For the <code>gcs</code> plugin, this identifies the <a href="https://cloud.google.com/storage/docs/concepts-techniques#concepts">bucket</a> to use.</td>
</tr>
<tr>
<td><nobr><code>-restore_from_backup</code></nobr></td>
<td>Indicates that, when started with an empty MySQL instance, the tablet should restore the most recent backup from the specified storage plugin.</td>
</tr>
</tbody>
</table>

### Authentication

Note that for the Google Cloud Storage plugin, we currently only support
[Application Default Credentials](https://developers.google.com/identity/protocols/application-default-credentials),
which means that access to Cloud Storage is automatically granted by virtue of
the fact that you're already running within Google Compute Engine or Container Engine.

For this to work, the GCE instances must have been created with the
[scope](https://cloud.google.com/compute/docs/authentication#using) that grants
read-write access to Cloud Storage. When using Container Engine, you can do this
for all the instances it creates by adding `--scopes storage-rw` to the
`gcloud container clusters create` command as shown in the [Vitess on Kubernetes guide]
(http://vitess.io/getting-started/#start-a-container-engine-cluster).

## Creating a backup

Run the following vtctl command to create a backup:
Expand Down Expand Up @@ -74,7 +100,7 @@ In response to this command, the designated tablet performs the following sequen
## Restoring a backup

When a tablet starts, Vitess checks the value of the
<code>--restore_from_backup</code> command-line flag to determine whether
<code>-restore_from_backup</code> command-line flag to determine whether
to restore a backup to that tablet.

* If the flag is present, Vitess tries to restore the most recent backup
Expand Down Expand Up @@ -187,3 +213,4 @@ can control the concurrency using command-line flags:

If the network link is fast enough, the concurrency matches the CPU
usage of the process during the backup or restore process.

Loading

0 comments on commit c976134

Please sign in to comment.