Hi everyone,
Hoping someone can help me out. I’m using DigitalOcean spaces and I want to back-up spaces to another space in another region.
I’m using the Node.js library “@aws-sdk/client-s3”. When I use the “CopyObjectCommand” to copy files between spaces in the same region it works perfectly fine. However, when I try to do it across regions it no longer works.
My flow: I instantiate a client in the “Origin” region, like this:
GetOriginClient(Space){
return new S3Client({
region: Space.region,
endpoint: "https://"+Space.region+".digitaloceanspaces.com",
credentials:{
accessKeyId:process.env.DO_SPACES_ACCESS_KEY,
secretAccessKey:process.env.DO_SPACES_ACCESS_SECRET
}
});
}
I then use “ListObjectsCommand” to get all the keys in the Origin space, which also works fine. Next I instantiate a DestinationClient in the same way, except in a different region. Finally, I instantiate a CopyObject command for each of the Objects i received, with the following params:
{
Bucket: 'destination-bucket'
CopySource: 'origin-bucket/backup/folder/subfolder/file.txt',
Key: 'folder/subfolder/file.txt'
}
I also tried adding the source region (but i read this is not nescecery):
{
Bucket: 'destination-bucket',
CopySource: 'ams3/origin-bucket/backup/folder/subfolder/file.txt',
Key: 'folder/subfolder/file.txt'
}
Getting error code 404, Code: ‘NoSuchBucket’. Any ideas?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Heya,
On top of what’s already been mentioned I would like to add that spaces can also be backed-up using snapshooter.
Spaces are very reliable, but it’s always a good idea to back things up. Snapshooter (https://snapshooter.com/) and Flexify (https://flexify.io/) both have the ability to replicate data to another bucket in another region on a scheduled basis. You can also run free a tool like rclone (https://rclone.org/) paired with a cron job to copy files to another bucket in another region on a regular schedule.
Regards
Hey!
Indeed, the
CopyObjectCommand
is not supported by the Spaces API. You can find a complete list of the Spaces API Reference Documentation here:I’ve just tested your code and indeed I’m getting the same error as you mentioned.
The best thing to do to get your voice heard regarding this would be to head over to our Product Ideas board and post a new idea, including as much information as possible for what you’d like to see implemented.
Feel free to share the link to the idea here so other people and me could upvote it!
In the meantime, a workaround would be to manually handle the copying process. This involves two main steps:
Download the Object from the Origin Space: Use the SDK to download the object from the origin space to your local server or a temporary storage location.
Upload the Object to the Destination Space: Once the object is downloaded, use the SDK again to upload it to the destination space.
Here is an example code that I’ve tested and can confirm that is working:
Hope that helps!
- Bobby.