api.video is the video infrastructure for product builders. Lightning fast video APIs for integrating, scaling, and managing on-demand & low latency live streaming features in your app.
api.video provides you with a convenient way of making a backup of your transcoded videos. With the current script, you'll be able to backup the videos to Google Storage, Azure Storage account and Amazon S3.
What we will need to run the script?
Depending on where you are going to backup your videos, you will need to prepare few things for the script and change keys in the .env
file.
from api.video, you'll need to get the API key.
- api.video API key, you can find the information on how to retrieve the API key in the Retrieve your api.video API key guide
- api.video Cold Storage script
- Node.js and npm, you can find the installation instructions here
- Typescript, you can find the installation instructions here
If you are preparing to backup to Azure Storage account, you can find the credentials you'll need below
- Azure Account Key, or use any other credential system that Azure provides
- Azure storage account name
Getting the Azure Storage Account name
- Navigate to your Azure portal
- Click on Storage Account
- You’ll find the Storage Account in the list
Preparing to the backup to Google account, you can follow the below steps. You will need to create a service account for the Storage account
- On Google Cloud Platform, navigate to the menu and select
APIs and services
- Select
Enabled APIs and services
- Click on
+ ENABLE APIS AND SERVICES
- Search for
Storage
and selectStorage Cloud
- If the API is not enabled, click on
Enable API
, andManage
- In the
API services details
click on+ Create credentials
- Select
Service account
- Fill out the details in the
Create Service Account
screen, click onCreate and Continue
- In the optional pane
Grant this service account access to the project
grant the Storage Admin role and click continue - Add the user to the service account and click
Done
- On the
API/Service details
click on the Service account that was just created, under Service Accounts - In the Service Account screen, navigate to the
Keys
tab - Click on
Add Key
andCreate new key
, a pop-up will appear, selectJSON
and thenCreate
. - This action will trigger a download of a JSON file that will storage on your machine/
- Copy the content of the JSON file
- Copy the content into the
.env
in theGCP_KEY
parameter. Note that the parameter should be a string, so encapsulate the JSON into''
For Amazon S3, you need to get the Access Key, Secret Key and region.
- Get the Amazon S3 credentials
- Copy the region from the console
After you’ve got all the keys and installed node.js, npm and typescript, you can proceed with cloning the script from GitHub.
Once you are in the script directory, install the dependencies
$ 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 the provider and api.video.
Make sure to mark the PROVIDER
value, which will indicate the script where to run the backup. The possible values for the PROVIDER
parameter are:
google
aws
azure
Note that, you only need to fill out the credentials for the provider you chose. You can only choose one provider at a time.
# possible providers: google, aws, azure
PROVIDER = ""
# api.video API key
APIVIDEO_API_KEY = "api_video_key"
# the name of the bucket on Google Amazon S3 or the container on Azure Storage
SPACE_NAME = ""
# Azure credentials
AZURE_ACCOUNT_KEY = ""
AZURE_STORAGE_ACCOUNT_NAME = ""
# Amazon S3 credentials
AWS_ACCESS_KEY_ID = ""
AWS_SECRET_ACCESS_KEY = ""
AWS_REGION = ""
# Google credentails
GCP_KEY = '{
}'
Don’t forget to save the file.
Once all the keys are 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:
$ npm run build
After the script was built, it’s time to run it:
$ npm run backup
If you have any questions, ask us in the community