Backup of attachments

72 views
Skip to first unread message

Yuzkan

unread,
Nov 22, 2014, 8:22:48 AM11/22/14
to mobile-c...@googlegroups.com
Hello,

It seems that attachments are stored only within Couchbase Sync Gateway and there is no way to access them from Couchbase.
We are using Sync Gateway's shadowing feature for synchronization and when we work with documents that have no attachments it is safe to drop the shadow bucket and re-create it again because data will be shadowed from the main bucket.

But when we work with attachments re-creating the shadow bucket is not possible because it will not restore attachments. Because of that documents that had attachments will not be synchronized with devices even though users have access to those documents.

Is there a way to backup the attachments? And is there a safe way to re-create shadow bucket without loosing any data?

Thanks,
Yuzkan

Yuzkan

unread,
Nov 22, 2014, 10:36:03 AM11/22/14
to mobile-c...@googlegroups.com
Actually I just saw that attachments are stored as documents within the shadow bucket. So it doesn't seem possible to delete and re-create shadow bucket safely.

Jens Alfke

unread,
Nov 22, 2014, 2:19:15 PM11/22/14
to mobile-c...@googlegroups.com
On Nov 22, 2014, at 5:22 AM, Yuzkan <yuzkan.m...@softwaregroup-bg.com> wrote:

It seems that attachments are stored only within Couchbase Sync Gateway and there is no way to access them from Couchbase. 

They're stored in the gateway's bucket as documents with IDs like "_sync:att:xxxxxx" where 'xxxxxx' is a hex SHA-1 digest of the attachment contents. (This may change in the future. Couchbase Server is not optimized for storing large documents and has a hard limit of 20MB. We plan to move attachments into some sort of distributed filesystem at some point.)

We are using Sync Gateway's shadowing feature for synchronization and when we work with documents that have no attachments it is safe to drop the shadow bucket and re-create it again because data will be shadowed from the main bucket.

Yes, there wasn't any clear way to put the attachments into the app bucket. It didn't seem right to copy them over as blobs with weird magic names.

But when we work with attachments re-creating the shadow bucket is not possible because it will not restore attachments. Because of that documents that had attachments will not be synchronized with devices even though users have access to those documents.

Unfortunately that's true. Do you have a need to delete and restore the shadow/gateway bucket?

A workaround would be to create an external process to watch the gateway's _changes feed and look for revisions with attachments, then copy them out to your own storage.

—Jens
Reply all
Reply to author
Forward
0 new messages