Skip to content

Commit

Permalink
Merge pull request #291 from apivideo/back-and-cold-storage-update
Browse files Browse the repository at this point in the history
Backup & Cold Storage articles addition
  • Loading branch information
szekelyzol authored Oct 10, 2023
2 parents 2fb51ce + 5812c66 commit efc80e4
Show file tree
Hide file tree
Showing 20 changed files with 234 additions and 8 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
92 changes: 92 additions & 0 deletions templates/documentation/vod/amazon-cold-storage-backup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
---
title: "Backup your videos to Amazon S3"
slug: "amazon-cold-storage-backup"
meta:
description: Backup videos uploaded to api.video to Amazon Storage account with a simple script.
---
# Video backup to Azure

At [api.video](https://api.video/) we understand that sometimes, you want to make sure that your videos are safe and secure. Although api.video has a backup and disaster recovery plan, it’s up to you to decide if you want an extra backup resource or if you would like to use api.video just to transcode your videos but eventually store them on a different resource.

That’s why, we’ve created this guide so you can store the videos you’ve already transcoded with [api.video](https://api.video/) on a file storage resource.

## How it’s done?

This guide will explain how you can store your transcoded videos on Amazon S3 Account. In short, all you need to do is run a small script that will copy the videos from [api.video](https://api.video/) to Azure. The videos will be kept on api.video as well, however, if you wish to delete them you can do so by leveraging the `DELETE /videos` endpoint, more information can be found [here](https://docs.api.video/vod/delete-a-video).

## Preparation

**What we will need to run the script?**

1. **[api.video](https://api.video/) API key**, you can find the information on how to retrieve the <a href="https://docs.api.video/reference/authentication-guide#retrieve-your-apivideo-api-key" target="_blank">API key in the Retrieve your api.video API key guide</a>
2. <a href="https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/getting-started-nodejs.html#getting-started-nodejs-credentials" target="_blank">Amazon S3 credentials</a>
3. Copy the Amazon S3 region from the console
4. api.video <a href="https://github.com/apivideo/backup-cold-storage" target="_blank">Cold Storage script</a>,
5. **Node.js** and **npm**, you can find the installation instructions <a href="https://docs.npmjs.com/downloading-and-installing-node-js-and-npm" target="_blank">here</a>
6. **Typescript**, you can find the installation instructions <a href="https://www.npmjs.com/package/typescript" target="_blank">here</a>

### Getting the Amazon S3 credentials

You can find the guide of getting the Amazon S3 Access Key id and Secret Key [here](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/getting-started-nodejs.html#getting-started-nodejs-credentials)

## Getting Started

After you’ve got all the keys and installed node.js, npm and typescript, you can proceed with cloning the script from GitHub.

### Cloning the Cold Storage script

1. In the command line enter the following

```bash
$ git clone https://github.com/apivideo/backup-cold-storage
```

1. Once the script is cloned, you can navigate the script directory

```bash
$ cd back-cold-storage
```

### Setting up the script

Once you are in the script directory, install the dependencies

```bash
$ npm install
```

After the dependencies are installed, we will need to enter the credentials we have copied in the preparation phase.

Edit the `.env` file and replace the following with the keys you've received from Azure and [api.video](https://api.video/).

```bash
# possible providers: google, aws, azure
PROVIDER = "aws"

# api.video API key
APIVIDEO_API_KEY = "api_video_api_key"

# the name of the bucket on Google Amazon S3 or the container on Azure Storage
SPACE_NAME = "your_bucket_name"

# Amazon S3 credentials
AWS_ACCESS_KEY_ID = "amazon_access_key_id"
AWS_SECRET_ACCESS_KEY = "amazon_secret_key"
AWS_REGION = "s3_bucket_region"
```

Don’t forget to save the file.

## Running the backup

Once you've got all the keys in place in the `.env` file, it's time to run the script. As we are running the script on TypeScript, we will need to build it first, hence, the first command you need to run in the script folder is:

```bash
$ npm run build
```

After the script was built, it’s time to run it:

```bash
$ npm run backup
```
23 changes: 16 additions & 7 deletions templates/documentation/vod/azure-cold-storage-backup.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This guide will explain how you can store your transcoded videos on Azure Storag
1. **[api.video](https://api.video/) API key**, you can find the information on how to retrieve the <a href="https://docs.api.video/reference/authentication-guide#retrieve-your-apivideo-api-key" target="_blank">API key in the Retrieve your api.video API key guide</a>
2. <a href="https://learn.microsoft.com/en-us/azure/storage/common/storage-account-keys-manage?tabs=azure-portal" target="_blank">Azure Account Key</a>, or use any other credential system that Azure provides
3. Azure storage account name
4. api.video <a href="https://github.com/apivideo/azure-cold-storage" target="_blank">Cold Storage script</a>,
4. api.video <a href="https://github.com/apivideo/backup-cold-storage" target="_blank">Cold Storage script</a>,
5. **Node.js** and **npm**, you can find the installation instructions <a href="https://docs.npmjs.com/downloading-and-installing-node-js-and-npm" target="_blank">here</a>
6. **Typescript**, you can find the installation instructions <a href="https://www.npmjs.com/package/typescript" target="_blank">here</a>

Expand All @@ -40,13 +40,13 @@ After you’ve got all the keys and installed node.js, npm and typescript, you c
1. In the command line enter the following

```bash
$ git clone https://github.com/apivideo/azure-cold-storage
$ git clone https://github.com/apivideo/backup-cold-storage
```

1. Once the script is cloned, you can navigate the script directory
2. Once the script is cloned, you can navigate the script directory

```bash
$ cd azure-cold-storage
$ cd backup-cold-storage
```

### Setting up the script
Expand All @@ -62,9 +62,18 @@ After the dependencies are installed, we will need to enter the credentials we h
Edit the `.env` file and replace the following with the keys you've received from Azure and [api.video](https://api.video/).

```bash
APIVIDEO_API_KEY = "apivideo_api_key"
AZURE_ACCOUNT_KEY = "Azure_account_key"
AZURE_STORAGE_ACCOUNT = "Your_azure_storage_account"
# possible providers: google, aws, azure
PROVIDER = "azure"

# api.video API key
APIVIDEO_API_KEY = "api_video_api_key"

# the name of the bucket on Google Amazon S3 or the container on Azure Storage
SPACE_NAME = "azure_container_name"

# Azure credentials
AZURE_ACCOUNT_KEY = "azure_account_key"
AZURE_STORAGE_ACCOUNT_NAME = "azure_storage_account_name"
```

Don’t forget to save the file.
Expand Down
2 changes: 2 additions & 0 deletions templates/documentation/vod/backup-and-cold-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Below, you will find the scripts that are available for your disposale in order

<div class="hagrid">

{% include "_partials/hagrid-item.md" title: "Amazon", image: "/_assets/get-started/migration-guide/Amazon-S3-Logo.svg", subtitle: "S3", link: "./amazon-cold-storage-backup.md" %}
{% include "_partials/hagrid-item.md" title: "Google", image: "/_assets/get-started/migration-guide/Google-Storage-Logo.svg", subtitle: "Storage account", link: "./google-cold-storage-backup.md" %}
{% include "_partials/hagrid-item.md" title: "Azure", image: "/_assets/get-started/migration-guide/Microsoft_Azure.svg", subtitle: "Storage account", link: "./azure-cold-storage-backup.md" %}

</div>
118 changes: 118 additions & 0 deletions templates/documentation/vod/google-cold-storage-backup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
---
title: "Backup your videos to Google Storage account"
slug: "google-cold-storage-backup"
meta:
description: Backup videos uploaded to api.video to Google Storage account with a simple script.
---
# Video backup to Azure

At [api.video](https://api.video/) we understand that sometimes, you want to make sure that your videos are safe and secure. Although api.video has a backup and disaster recovery plan, it’s up to you to decide if you want an extra backup resource or if you would like to use api.video just to transcode your videos but eventually store them on a different resource.

That’s why, we’ve created this guide so you can store the videos you’ve already transcoded with [api.video](https://api.video/) on a file storage resource.

## How it’s done?

This guide will explain how you can store your transcoded videos on Amazon S3 Account. In short, all you need to do is run a small script that will copy the videos from [api.video](https://api.video/) to Azure. The videos will be kept on api.video as well, however, if you wish to delete them you can do so by leveraging the `DELETE /videos` endpoint, more information can be found [here](https://docs.api.video/vod/delete-a-video).

## Preparation

**What we will need to run the script?**

1. **[api.video](https://api.video/) API key**, you can find the information on how to retrieve the <a href="https://docs.api.video/reference/authentication-guide#retrieve-your-apivideo-api-key" target="_blank">API key in the Retrieve your api.video API key guide</a>
2. Preparing to the backup to Google account, you can follow the below steps. You will need to <a href="https://support.google.com/a/answer/7378726?sjid=1556077145065480779-EU" target="_blank">create a service account for the Storage account</a>
4. api.video <a href="https://github.com/apivideo/backup-cold-storage" target="_blank">Cold Storage script</a>,
5. **Node.js** and **npm**, you can find the installation instructions <a href="https://docs.npmjs.com/downloading-and-installing-node-js-and-npm" target="_blank">here</a>
6. **Typescript**, you can find the installation instructions <a href="https://www.npmjs.com/package/typescript" target="_blank">here</a>

### Setting up service account and getting the credentials

- On Google Cloud Platform, navigate to the menu and select `APIs and services`
- Select `Enabled APIs and services`
![](/_assets/vod/backup-and-cold-storage//gcp-1-api-services.png)
- Click on `+ ENABLE APIS AND SERVICES`
![](/_assets/vod/backup-and-cold-storage/gcp-2-enable-api.png)
- Search for `Storage` and select `Storage Cloud`
![](/_assets/vod/backup-and-cold-storage/gcp-3-cloud-storage.png)
- If the API is not enabled, click on `Enable API`, and `Manage`
- In the `API services details` click on `+ Create credentials`
- Select `Service account`
![](/_assets/vod/backup-and-cold-storage/gcp-4-create-service-account.png)
- Fill out the details in the `Create Service Account` screen, click on `Create and Continue`
![](/_assets/vod/backup-and-cold-storage/gcp-5-add-service-account.png)
- In the optional pane `Grant this service account access to the project` grant the Storage Admin role and click continue
![](/_assets/vod/backup-and-cold-storage/gcp-6-add-roles.png)
- Add the user to the service account and click `Done`
![](/_assets/vod/backup-and-cold-storage/gcp-7-grant-user-access.png)
- On the `API/Service details` click on the Service account that was just created, under Service Accounts
![](/_assets/vod/backup-and-cold-storage/gcp-8-navigate-to-service-account.png)
- In the Service Account screen, navigate to the `Keys`tab
![](/_assets/vod/backup-and-cold-storage/gcp-9-navigate-to-keys-add-key.png)
- Click on `Add Key` and `Create new key`, a pop-up will appear, select `JSON` and then `Create`.
![](/_assets/vod/backup-and-cold-storage/gcp-10-export-json.png)
- This action will trigger a download of a JSON file that will storage on your machine/
![](/_assets/vod/backup-and-cold-storage/gcp-11-json-confirmation.png)
- Copy the content of the JSON file
![](/_assets/vod/backup-and-cold-storage/gcp-12-open-json.png)
- Copy the content into the `.env` in the `GCP_KEY` parameter. Note that the parameter should be a string, so encapsulate the JSON into `''`
![](/_assets/vod/backup-and-cold-storage/gcp-14-env-file.png)

## Getting Started

After you’ve got all the keys and installed node.js, npm and typescript, you can proceed with cloning the script from GitHub.

### Cloning the Cold Storage script

1. In the command line enter the following

```bash
$ git clone https://github.com/apivideo/backup-cold-storage
```

1. Once the script is cloned, you can navigate the script directory

```bash
$ cd back-cold-storage
```

### Setting up the script

Once you are in the script directory, install the dependencies

```bash
$ npm install
```

After the dependencies are installed, we will need to enter the credentials we have copied in the preparation phase.

Edit the `.env` file and replace the following with the keys you've received from Azure and [api.video](https://api.video/).

```bash
# possible providers: google, aws, azure
PROVIDER = "google"

# api.video API key
APIVIDEO_API_KEY = "apivideo_api_key"

# the name of the bucket on Google Amazon S3 or the container on Azure Storage
SPACE_NAME = "google_bucket_name"

# Google credentails
GCP_KEY = '{ google json key
}'
```

Don’t forget to save the file.

## Running the backup

Once you've got all the keys in place in the `.env` file, it's time to run the script. As we are running the script on TypeScript, we will need to build it first, hence, the first command you need to run in the script folder is:

```bash
$ npm run build
```

After the script was built, it’s time to run it:

```bash
$ npm run backup
```
6 changes: 5 additions & 1 deletion templates/documentation/vod/navigation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@
href: /vod/backup-and-cold-storage.md
collapsed: true
items:
- label: Video backup to Azure
- label: Video backup to Amazon S3
href: /vod/amazon-cold-storage-backup.md
- label: Video backup to Google Storage account
href: /vod/google-cold-storage-backup.md
- label: Video backup to Azure Storage account
href: /vod/azure-cold-storage-backup.md

- heading: Video management
Expand Down

0 comments on commit efc80e4

Please sign in to comment.