Programmable Media

Backups and version management

Last updated: Aug-25-2024

Backing up your assets allows you to maintain a version history of individual assets, letting you view, download or restore previous revisions as well as retrieving deleted assets if needed. When you upload an asset while backups are enabled, the uploaded file is automatically backed up. You can either use Cloudinary's default backup storage, or set up your own storage bucket (paid accounts only).

Overview

Watch this video tutorial for an overview:

Enabling automatic backup

By default, backup is turned off. Enabling automatic backup means that every uploaded asset is also copied to a secondary write-protected location, while keeping multiple revisions per file. If using Cloudinary's default backup storage, this counts against your storage usage.

Important
If you intend to use your own backup storage, do not enable automatic backup until you set up your storage bucket.

To enable backup of your Cloudinary-managed assets, set Automatic backup to Enabled in the Upload page of the Cloudinary Console Settings and click Save to activate backups for all newly uploaded assets.

Screenshot of automatic backup setting

To back up the existing files in your product environment, click Perform initial backup. When the backup is complete, an email is sent to the notification email address that you specify in the confirmation box.

Notes
  • If you have many assets in your product environment at the time you initiate the backup, you will be routed to a page where you can request for Cloudinary customer support to perform the initial backup.
  • An asset backup occurs when the asset itself is replaced with a new version. Other changes to an asset, such as updates to tags or metadata do not trigger a backup.
  • Remotely fetched assets, including Facebook and Twitter profile pictures, are not backed up because they can be automatically re-created at any time. In addition, Cloudinary keeps backup copies only for your original assets and not the derived (transformed) versions of these originals, as these too can be re-generated on demand.

Using your own backup storage

Paid accounts have the option to back up to a designated storage bucket, either through Amazon Simple Storage Service (Amazon S3) or Google Cloud Storage, instead of using Cloudinary's default backup location. These backups do not count against your Cloudinary storage usage.

Notes
  • When using your own backup storage, the backup location should not be touched or modified in any way. Additionally, no life-cycle policy (archiving, deletion), no versioning, and no object locks should be enforced on that location.
  • If you have already backed up files to one storage location (including Cloudinary's default backup), then change to a different storage bucket, we recommend contacting support to ensure that a full backup is written to your new bucket.

To enable this option, your storage bucket must be whitelisted. This requires the following steps:

  1. Add an empty file to your bucket with your cloud name as the filename, under the following folder structure: .wellknown/cloudinary/<your_cloud_name>

    • By adding this file, you indicate that you have access to this bucket and that you permit Cloudinary to access and modify this bucket's contents.
    • If you want this bucket to be whitelisted for more than one Cloudinary product environment, you can add an appropriately named file for each cloud name.
  2. Provide Cloudinary with information and access to your bucket:
    - Backing up to Amazon S3
    - Backing up to Google Cloud Storage

Backing up to Amazon S3

To configure automatic backups to an Amazon S3 bucket:

  1. Create your Amazon S3 bucket, and name it with your company name and region, for example: cloudinary-backup-wodup-us-east-2.
  2. Grant full access permissions to Cloudinary's AWS account, info@cloudinary.com, using one of the following methods:

    • AWS Console: Set up the bucket policy using this JSON code. Make sure to replace <your_bucket_name> and <bucket-region> with your bucket's actual values.
    • AWS CloudFormation: Use CloudinaryS3Backup.json within AWS CloudFormation to create the backup bucket.
      Note
      If at a later point you need to update permissions on an existing S3 buckets, changes may take some time to propagate, and you may not see the changes taking effect right away.
  3. In your Cloudinary Console Settings, go to the Upload page. Enter the name of your S3 bucket in the Use your own backup bucket field and click Save.

    Screenshot of setting S3 bucket

  4. Enable automatic backup and click Perform initial backup to back up your current assets to your S3 bucket. Any new uploaded assets will be automatically backed up to this bucket.

Backing up to Google Cloud Storage

To configure automatic backups to a Google Cloud storage bucket:

  1. Create a Google Cloud storage bucket using this naming convention:
    {XXX}-gs-cld, for example: mycloud-gs-cld

    Make sure to select the Fine-grained access control method when creating the bucket.

  2. Grant full access permissions to Cloudinary by adding service@cloudinary-gcs-production.iam.gserviceaccount.com as a member with the Storage Object Admin role.

  3. In your Cloudinary Console Settings, go to the Upload page. Enter the name of your Google Cloud bucket in the Use your own backup bucket field and click Save.

    Screenshot of setting Google Cloud bucket

  4. Enable automatic backup and click Perform initial backup to back up your current assets to your Google Cloud storage bucket. Any new uploaded assets will be automatically backed up to this bucket.

Overriding the global backup setting

You can selectively override the global backup setting when uploading a specific file by setting the backup parameter in the upload API call.

For example, if the global backup setting isn't enabled, setting the backup parameter to true when uploading the file sample.jpg, ensures that the uploaded file is backed up:

Deleting backups

To delete backup storage that you no longer require:

  • If you are using Cloudinary's default backup storage, contact the support team with your cloud name and last four characters of your API secret. The backup will be deleted, freeing up space in your product environment.

  • If you are using your own backup storage, you can delete this yourself, but you should contact the support team to update the database records for your backups.

Note
To pick and choose versions of individual files to be deleted from your backup storage, use the Delete backed up versions of resources method of the Admin API.

Versioning

You can list and restore assets from backup either programmatically, or via the Media Library.

Managing asset versions programmatically

Programmatically, you can:

Getting details of an asset's versions

To see details of backed up versions for a specific asset, use the resource method of the Admin API, setting the versions parameter to true. For example:

Sample response:

Restoring a version of an asset

To restore a specific version of an asset, use the restore method of the Admin API together with the versions parameter set to the version_id of the specific version. You can use arrays to specify more than one asset and each asset's corresponding version to restore. For example:

Downloading a version of an asset

To download a backed up version of an asset without restoring it, use the download_backup method.

  • The endpoint returns the specified version of the asset in bytes.
  • The SDKs return a URL of the asset that can be used to download that version of the asset (within an hour of the request).

For example, to return the URL of a backed up version of an asset with asset_id of 62c2a18d622be7e190d21df8e05b1416 and version_id of 26fe6d95df856f6ae12f5678be94516a, use the following syntax (the cURL example returns the asset in bytes):

The SDK methods return the URL to download the requested backed up version of the asset, as follows:

The URL returned in the response is valid for an hour.

Deleting a version of an asset

Important
Deleting from backup is irreversible and any deleted versions from a backed up asset can't be recovered in any way.

To delete a specific version of an asset, use the delete backed up versions of a resource method of the Admin API together with the version_ids of the specific versions to delete. For example:

Managing asset versions via the Media Library

You can list, preview and restore previous versions of an asset from the asset management drill down page by clicking Version History from the kebab menu:

screenshot of manage page with 'Version History' highlighted

To preview a specific version of the asset, click Open in new tab. To restore a previous version, click the Restore version history link next to the listed version.

screenshot of revisions

Restoring deleted assets from backup

You can restore deleted assets from backup either programmatically, or via the Media Library.

Note
When backed up assets are deleted, the public ID of the deleted asset is reserved by the backup system so that it will be available for future restoring along with its full backup history. This means that you can't rename another asset to use that public ID, as those assets have their own backup history.

You can, however, upload a new asset with the same public ID as a previously deleted and backed-up asset. In that case, the newly uploaded asset becomes the latest version of the backed-up asset.

Restoring deleted assets programmatically

To find specific assets that you want to restore from backup programmatically, you can use the search method with status=deleted together with other search options to narrow down the results.

Once you have found your deleted assets, you can restore them from backup programmatically using the restore method of the Admin API. If no versions are specified, the latest backed up version of the asset is restored. For example, to restore deleted assets with the public_ids 'image1' and 'image2':

To restore a specific version of a deleted asset, use the versions parameter, as shown in Restoring a version of an asset.

Restoring deleted assets via the Media Library

To restore deleted assets through the Media Library, navigate to Advanced Search. From the Delivery type filter, select assets of type Deleted asset.

Screenshot of deleted assets

You can optionally narrow the search down further using other Advanced Search filters, then double-click the asset you want to restore. Select a specific version to restore as described in Versioning, either by clicking Version History in the Preview area or the kebab menu of the asset management drill down page, and then clicking Restore visual content.

Restoring deleted assets video tutorial

Watch this video tutorial to learn more about restoring deleted assets in the Media Library:

✔️ Feedback sent!

Rate this page: