Attachments on S3
-
Hi,
I’m trying to migrate my attachment storage from “files” to “s3”.
Therefore I’ve created a new bucket in eu-central-1 (EU Frankfurt) and uploaded all the attachments to the root of the bucket:root@srv1 /mnt/s3 # ll total 10 drwx------ 1 root root 0 Jan 1 1970 ./ drwxr-xr-x 3 root root 4096 Feb 10 21:31 ../ drwxr-x--- 1 kopano kopano 0 Sep 5 23:38 0/ drwxr-x--- 1 kopano kopano 0 Sep 5 23:38 1/ drwxr-x--- 1 kopano kopano 0 Sep 5 23:38 2/ drwxr-x--- 1 kopano kopano 0 Sep 5 23:38 3/ drwxr-x--- 1 kopano kopano 0 Sep 5 23:38 4/ drwxr-x--- 1 kopano kopano 0 Sep 5 23:38 5/ drwxr-x--- 1 kopano kopano 0 Sep 5 23:38 6/ drwxr-x--- 1 kopano kopano 0 Sep 5 23:38 7/ drwxr-x--- 1 kopano kopano 0 Sep 5 23:38 8/ drwxr-x--- 1 kopano kopano 0 Sep 5 23:38 9/
I’ve modified the server.cfg as below:
attachment_storage = s3 #attachment_files_fsync = yes attachment_path = #attachment_compression = 6 attachment_s3_hostname = s3-eu-central-1.amazonaws.com attachment_s3_region = eu-central-1 attachment_s3_protocol = https attachment_s3_uristyle = virtualhost attachment_s3_accesskeyid = xxxXXxxxXXXxxx attachment_s3_secretaccesskey = xxxXXxxX+xxxXX+xxXxxxXXxxX attachment_s3_bucketname = mybucketname
I’ve started the kopano-server first time with parameter --ignore-attachment-storage-conflict
On selecting a attachment within webapp I’ve got errors and it’s not working:
Feb 10 23:04:56 srv1 kopano-server[4016]: S3: Amazon return status ErrorNoSuchKey, error: The specified key does not exist., resource: "<none>" Feb 10 23:04:56 srv1 kopano-server[4016]: S3: Amazon error details: Key: /2659 Feb 10 23:04:56 srv1 kopano-server[4016]: S3: Amazon error details: RequestId: 73B73EFB0B30F395 Feb 10 23:04:56 srv1 kopano-server[4016]: S3: Amazon error details: HostId: e+xUi468MB5uO4G7+9gyjBeWZZRT5nG187pwMN2k1MyuzrDXkMKhuQhm033r+TwCIkEIAEjOyy8=
I’ve searched a lot about documentation regarding S3 without luck. I’ve read a lot about the “ErrorNuSuchKey” error in other S3 applications, but it mostly seems to be an issue that the files doesnt exists.
Do you have any hint for me what might be the root cause?
I’ve read in the topic Topic: migration of attachment-storage from files to S3
that the file structure should be the same. In this case this shouldn’t be an issue.Thanks in advance!
Regards
Timo -
Hi @tkempken ,
thanks for bringing that old topic back to my memory. I have just corrected my statement in it. It was actually not true that the s3 backend uses the same file structure. Instead all attachments are simply stored in a single folder.
-
Hi @fbartels ,
thanks for your quick reply.
That’s what I’ve expected as the GET requests to S3 are /<attachmentid> instead of /<folder_id>/<attachmentid>.
To proceed in this case it’s necessary to rebuild the folder structure. With help of a small script which move the files and rename them properly this should be possible. Do you have some scripts or hints from the support site which can be used ? I read in another topic that the support is familar with these tasks.Thanks and wish you a good week
Regards
Timo -
@tkempken said in Attachments on S3:
Do you have some scripts or hints from the support site which can be used ?
This is a community forum and I am not part of our support team. you can find instructions on how to reach our support at https://kopano.com/support-info/.
-
Hi all,
as the amount of documentation about storing attachments in S3 storage is not much I’ve done some reverse engineering with a bit of try&error on my own and would like to share my earned knowledge with you. Please keep in mind that I’m not from the support stuff and just want to shed some light into the dark for other users.
Please do NOT copy & execute these commands without knowing what these commands do.
I will not take over any guarantee if you will result in data loss or destroy your environment.I’ve done the successful migration from “files” to “s3” with kopano-server version is 8.7.80.307.3 using my notes below:
pkill kopano-server (stop kopano server) mkdir /tmp/migrate cp -ar /var/lib/kopano/attachments /tmp/migrate cd /tmp/migrate mkdir kopano-attachments find -type f -exec mv {} kopano-attachments/ \; find -type d -empty -delete cd kopano-attachments gzip -d *.gz mv /var/lib/kopano/attachments /var/lib/kopano/attachments_old``
upload the folder kopano-attachments to your s3 bucket.
Change the configuration as follow:attachment_storage = s3 attachment_path = kopano-attachments (IMPORTANT: no leading / name of your subfolder in basket) #attachment_files_fsync = yes #attachment_compression = 6 attachment_s3_hostname = s3.eu-central-1.amazonaws.com attachment_s3_region = eu-central-1 attachment_s3_protocol = https attachment_s3_uristyle = path attachment_s3_accesskeyid = abc1234abc1234 attachment_s3_secretaccesskey = abc1234+abc1234+abc1234 attachment_s3_bucketname = mybasketname
At first start of kopano-server uses the parameter “ignore parameter” as attachment storage was moved
/usr/sbin/kopano-server -F --ignore-attachment-storage-conflict
Open some attachments within your webapp to see if they are downloading correctly.
After this stop the manually started kopano-server and start the service daemon again.
I hope these notes will help you to save your time and headache ;-)
If you like you can spent me a coffee ;-)@fbartels, thanks for your hint about the folder structure.
Regards
Timo