Best ways to copy files between two block devices
There are several options on how to transfer data from one volume to another. In this article we will cover two that should cover most use cases.
Option 1: dd to create a 'carbon copy' of volume
CARELESS USAGE OF dd CAN RESULT IN DATA LOSS dd overwrites the contents of the output file/device, please always double check that the if= points to input file/device, of= points to output file/device and those files/devices are not confused with other files/devices.
You can see the device path for each volume attached to instance in storage tab of selected instance
To create a carbon copy of input device and write it to other device/file simply run:
dd if=/path/to/input of=/path/to/output bs=96M status=progressIf we were intending to clone OS-viJ5Hd2x to Volume-2th9Aa6j (see the above picture), the command would be:
dd if=/dev/vda of=/dev/vdb bs=96M status=progressOption 2: rsync to copy folders and files between two mounted volumes
First, install rclone, a powerful utility for copying files locally and from/to remote disks.
apt install rcloneThen the command to copy the files would be:
Change SRC folder you want to copy, change DST to destination folder where files from SRC should go to and adapt the --exclude flags to what you want to exclude. In case you need maximum performance you can add some flags to the above command and adapt their values to your setup:
Read more about these options at rclone flags.
Last updated
Was this helpful?