Tutorials · 4 min read

Create a backup of your videos in Amazon S3

It is always good to have a backup of your videos to be safe against accidental video deletion. Learn how to do it using api.video libraries.

Artem Matinian

October 20, 2023

The world is moving very fast, and although we don’t necessarily notice it, we are surrounded by bits and bytes. From the phone you are reading this article on, to the car you are driving, it is truly amazing how our technology is shaped by these bits and bytes. However, with all that magic, these bits and bytes are just digital items, and in an instance, a software glitch, a simple mistake, or physical harm can swiftly erase them.

That’s why api.video has built a strong infrastructure to make sure that in case of a mishap, the videos and data you’ve uploaded to api.video are safe. We have a disaster recovery plan to ensure you have a sound sleep at night.

Backing up & archiving videos at api.video

However, we also know that sometimes, you may want to make sure that you have your own backups for higher security. Various reasons for keeping these backups could be, to be safe against accidental video deletion or archiving your videos to an object storage.


For that reason, api.video has created a Backup and Cold Storage Library to help you backup or archive videos by sending them to the storage provider of your choice.


Using this library, you can backup or archive your videos into one of the popular storage providers – Google Cloud Storage account, Amazon S3 and Azure Storage.


Now you may ask, what does the script in the library do exactly?


The script will iterate through all the videos you have on your api.video account and send these videos to the provider of your choice. All you have to do is choose the provider, get your api.video API key and the provider’s credentials.


It’s worth mentioning, that the library is open source and you can modify it for your use case, for example, if you would like to delete the videos after backup. What you should know about the library in its current version (v1.0) as we speak:

  • All backed-up videos are kept and not deleted
  • Pagination of the api.video lists is not supported out of the box, however we plan to add it in the next version
  • Incremental backup is not supported. If you run the backup again, it will create duplicate files


You can find all the instructions for the library in our Backup & Cold Storage guides.

Step-by-step guide to create a backup of your videos in Amazon S3

Let’s see how you can create a backup of your videos in api.video to Amazon S3.


First and foremost, to start running the script, you will need an api.video account. If you haven’t uploaded videos yet to api.video, and you would like to test, make sure to register your sandbox account here.


Some other things you would need are:


Getting started

You can find the guide to get the Amazon S3 Access Key id and Secret Key here.


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

Open your terminal or command line and enter the following commands:


After the library has been cloned, navigate to the directory:


Setting up the script

Once you are in the library directory, install the dependencies


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 AWS and api.video.


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:


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


That’s it!


Now just sit back and relax while we take care of the backup process. The library will take the object of the video, and serve the link to the provider. The time to create the backup will vary depending on the amount of videos you have.

Try out more than 80 features for free

Access all the features for as long as you need.
No commitment or credit card required

Video API, simplified

Fully customizable API to manage everything video. From encoding to delivery, in minutes.

Built for Speed

The fastest video encoding platform. Serve your users globally with 140+ points of presence. 

Let end-users upload videos

Finally, an API that allows your end-users to upload videos and start live streams in a few clicks.


Volume discounts and usage-based pricing to ensure you don’t exceed your budget.