Yandex Cloud
Documentation
PresentationContact UsTry it for free
© 2026 Direct Cursus Technology L.L.C.
Architecture solutions
    • Recommendations on fault tolerance in Yandex Cloud
    • Restoring database clusters in case of an availability zone failure
    • Transferring a disk image to a third-party S3 storage
    • Configuring Cloud CDN when the origin is unavailable
    • Deploying a web app in a fault-tolerant configuration in Yandex Cloud
    • Hosting a static website in Yandex Cloud
    • MLOps management in Managed Service for GitLab

In this article:

  • Prepare a bucket and set up bucket access
  • Prepare a disk backup and an auxiliary VM
  • Install the utilities and save the key
  • Connect the bucket
  • Select a device and upload the image
  • Check the image in the storage
  • Complete the transfer
  • Restore the image to a separate disk
  • How to delete temporary resources
  1. Fault tolerance
  2. Transferring a disk image to a third-party S3 storage

Transferring a Yandex Compute Cloud disk image to a third-party provider's S3-compatible storage with an intermediate VM

Written by
Yandex Cloud
Updated at November 26, 2026
View in Markdown
  • Prepare a bucket and set up bucket access
  • Prepare a disk backup and an auxiliary VM
  • Install the utilities and save the key
  • Connect the bucket
  • Select a device and upload the image
  • Check the image in the storage
  • Complete the transfer
  • Restore the image to a separate disk
  • How to delete temporary resources

You can save a byte-for-byte backup of your Compute Cloud disk in another provider's object storage. Such a backup allows you to keep your data outside Yandex Cloud and use it for recovery.

In this guide, you will create a disk from a snapshot, connect it to an auxiliary Linux VM, and upload the disk or partition image with the help of s3fs, dd, and gzip. The result will be a compressed image in a .img.gz file. Creating and starting the VM based on a different provider will require a separate recovery.

Note

The example used a private Selectel bucket in the ru-7 region. For a different S3-compatible storage, replace the connection properties and check out the provider's requirements related to access and object sizes.

To transfer a disk image to an S3-compatible storage of a third-party provider:

  1. Prepare a bucket and access to it.
  2. Prepare a disk backup and an auxiliary VM.
  3. Install the utilities and save the key.
  4. Connect the bucket.
  5. Select a device and upload the image.
  6. Check the image in the storage.
  7. Complete the transfer.
  8. Restore the image to a separate disk.

If you no longer need the resources you created, delete them.

Prepare a bucket and set up bucket accessPrepare a bucket and set up bucket access

  1. Create a bucket in Selectel:

    • Specify a name, e.g., disk-snapshot-dr-bucket. If this name is taken, pick another one and replace it in the commands below.

    • Select private access.

    • Select the Path-Style addressing type used in the bucket connection command below.

    • Select the cold storage class.

      Warning

      Prior to uploading, read the pricing policy, including as pertains to data reading and minimum retention period.

  2. On the Connection tab, create an S3 key named disk-snapshot-bucket-key. In the key owner field, select Me for a one-time transfer or an individual Selectel service user for regular use.

  3. Give the service user permissions for the correct project and bucket:

    • Object reading and writing.
    • Viewing bucket contents.
    • Multipart upload operations.

    Requirements for roles are detailed in the s3fs connection guide.

  4. Save Access key and Secret key to a secure location. You will need them on the auxiliary VM.

Prepare a disk backup and an auxiliary VMPrepare a disk backup and an auxiliary VM

  1. If you do not yet have a snapshot of the disk you want to transfer to another cloud provider, create one.
  2. Create an auxiliary Ubuntu or Debian VM or use an existing one. Make sure you have HTTPS access to the Selectel endpoint.
  3. Create a disk from the snapshot in the same availability zone as the auxiliary VM.
  4. Connect the new disk to the auxiliary VM as an extra one.
  5. Connect to the auxiliary VM over SSH.

Warning

s3fs uses temporary files and local cache. Recording via gzip does not guarantee there will be no local buffering. Check for free space in /tmp or in the directory set by the tmpdir parameter of the s3fs utility: allow for a buffer up to the size of the uploaded compressed image.

Install the utilities and save the keyInstall the utilities and save the key

Execute the following commands until the end of the upload on the auxiliary VM in the same Bash session under root.

  1. Open the session and install the utilities:

    sudo -i
    apt-get update
    apt-get install -y s3fs gzip
    set -o pipefail
    umask 077
    

    pipefail will allow you to detect the dd error even if the next gzip command ends successfully.

  2. Enter the access keys for the external bucket:

    read -r -p "Access key: " S3_ACCESS_KEY
    read -r -p "Secret key: " S3_SECRET_KEY
    printf "\n"
    printf "%s:%s\n" "$S3_ACCESS_KEY" "$S3_SECRET_KEY" \
      > "$HOME/.passwd-s3fs"
    unset S3_ACCESS_KEY S3_SECRET_KEY
    chmod 600 "$HOME/.passwd-s3fs"
    

    In this session, the ~/.passwd-s3fs file resides at /root/.passwd-s3fs.

Connect the bucketConnect the bucket

  1. Create a mount directory:

    mkdir -p /dr-s3mount
    
  2. Mount the bucket:

    s3fs disk-snapshot-dr-bucket /dr-s3mount \
      -o passwd_file="$HOME/.passwd-s3fs" \
      -o endpoint=ru-7 -o url=https://s3.ru-7.storage.selcloud.ru \
      -o use_path_request_style -o max_dirty_data=512 -o ensure_diskfree=2048
    mountpoint /dr-s3mount
    

    Compare the region (endpoint) and S3 API endpoint (url) with the parameters on your bucket's connection tab. For a different provider, replace bucket name, region, and endpoint. Other s3fs parameters are described in the project reference.

Continue only after a successful mountpoint check.

Select a device and upload the imageSelect a device and upload the image

  1. View connected devices:

    lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS,MODEL,SERIAL
    

    Compare the size and ID with the disk info. The /dev/vda1 device represents only the partition, whereas /dev/vda, the whole disk including the partition table. The connected disk's name may be different on the auxiliary VM.

  2. Upload the image. The example shows the /dev/vda1 partition: replace SOURCE with a tried path to the disk or partition of interest.

    SOURCE=/dev/vda1
    IMAGE="$(hostname).$(basename "$SOURCE").$(date -u +%Y%m%dT%H%M%SZ).img.gz"
    export IMAGE
    
    dd if="$SOURCE" bs=4M status=progress | gzip -c > "/dr-s3mount/$IMAGE"
    

    pipefail allows you to detect the dd error even if gzip ends successfully. In the event of a failure, the object may remain incomplete, so do not use it for recovery.

    hostname in the file name refers to the auxiliary VM. Write the source disk ID separately.

Check the image in the storageCheck the image in the storage

  1. Unmount the bucket:

    cd /root
    umount /dr-s3mount
    

    If unmount ends with an error, fix the error before you continue.

  2. Connect the bucket again using the command from Connect the bucket. Reconnecting allows you to check the saved object, not the local cache data from the previous mount.

  3. In the Selectel control panel, make sure the object has appeared in the bucket, has a non-zero size, and its storage class is as selected.

  4. You can check the downloaded archive for integrity on another target VM:

    gzip -t "img_file.gz"
    

    Specify the name of the downloaded file instead of img_file.gz. The command reads the archive as a whole and checks it for integrity. This may take time. Be aware of the external provider's reading and outbound traffic charges.

Complete the transferComplete the transfer

Unmount the bucket on the auxiliary VM:

umount /dr-s3mount

Save the object name, source device, disk size, and backup time. Before you delete the source disk, do a trial recovery to a separate disk: gzip's integrity by itself does not prove that the system is able to load correctly.

Restore the image to a separate diskRestore the image to a separate disk

This method writes the image content to the target device byte for byte. Restore the whole disk image to a whole disk, and the partition image to a separate partition. The target disk or partition must be at least the size of the source.

Alert

All the target device data will be overwritten. If you are restoring a whole disk image, its partition table will be overwritten as well. A separate partition image does not contain the partition table of the source disk.

  1. Download .img.gz to a Linux VM, connect the target disk and identify its name:

    lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS,MODEL,SERIAL
    

    Make sure you selected an extra disk, not the VM's boot disk. The disk and its partitions must not be mounted. Unmount them before writing.

  2. Run the commands in Bash. Specify the name of the downloaded archive instead of IMAGE. Replace /dev/REPLACE_ME with the target disk, e.g., /dev/vdc, if using the whole disk image, or with the target partition, e.g., /dev/vdc1, if using a partition image:

    set -o pipefail
    IMAGE="node3.vdb.20261012T082919Z.img.gz"
    TARGET="/dev/REPLACE_ME"
    
    # Checking the archive for integrity before writing.
    gzip -t "$IMAGE" || exit 1
    
    # Unpacking directly to the disk without an .img in between.
    if ! gzip -dc "$IMAGE" |
      sudo dd of="$TARGET" bs=4M iflag=fullblock conv=fsync status=progress
    then
      echo "Restoration error. The target disk may be incomplete."
      exit 1
    fi
    echo "The image has been written to the disk."
    

How to delete temporary resourcesHow to delete temporary resources

Once the restoration is successfully tested, you can delete the unused resources:

  • Auxiliary VM
  • Disk backups
  • Snapshots

Was the article helpful?

Previous
Restoring database clusters in case of an availability zone failure
Next
Configuring Cloud CDN when the origin is unavailable
© 2026 Direct Cursus Technology L.L.C.