Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Liferay 7.0 Document Library Data Replication
When I upload and approve documents I would like to fully automate data replication in my Liferay Application between two data center databases and file systems. For example, when I upload a set of documents in my primary data center server and I approve those documents which put its in approve state, I would like those same documents copied to my DR server. Its pretty much the same step when I manually used the Import/Export wizard but would like to import/export using an automated process. The documents are stored in the default liferay store /liferay-ce-portal-7.0-ga3/data/document_library/20116. Can anyone suggest the bets approach to do this task? Is there a import/export API service I can call after the documents been approved?
Kevin Matthews:
What you've described is a cluster configuration. Geographically distributed clusters are notoriously hard, as there hasn't been much progress in the speed-of-light-development lately.
When I upload and approve documents I would like to fully automate data replication in my Liferay Application between two data center databases and file systems.
You will need the database and the filesystem replicated at the same time.
For a more decoupled system, you might want to look into remote transaction-log backups, and store your documents in the database. This way you'll have binary data in the database (a drawback for some) but the transaction log backup will enable you to just restore at a specific point in time without waiting for the other cluster machine's communication.
Unrelated: I don't recommend using the default (FileSystemStore) in production, rather use AdvancedFileSystemStore, as it will handle larger numbers of files way more gracefully.
Thanks for the response Alof however, we are not using a clustered environment as we are using CE 7.0 GA3 solution its more of a primary and secondary. And if we anticipate in the future adding more files we will take into consideration moving to AdvancedFileSystemStore.
However, I have a couple of questions as define as follows:1.) I have tested in one of my development server by using DBStore as suggested from this page https://portal.liferay.dev/docs/7-2/deploy/-/knowledge_base/d/using-the-dbstore. I have manually imported, application logo location and two documents successfully using the document library uploader and look into the DLContent which I am assuming the documents are stored as a BLOB data in the data_ column. However, when I use the Import/export portlet to import a LAR file which has all 188 documents I receive the following exception shown below in bold. Do you know what the cause of this exception? Can the Import/Export portlet work for documents stored in the DBStore (liferay database)? Is this exception due to fact that its looking for document stored in the DBStore (DLContent table)? How would I migrate all my documents or assets to the DBStore (liferay database)? Caused by: com.liferay.document.library.kernel.exception.NoSuchContentException: No DLContent exists with the key {companyId=20116, repositoryId=20147, path=20, version=1.0}
at com.liferay.portlet.documentlibrary.service.persistence.impl.DLContentPersistenceImpl.findByC_R_P_V(DLContentPersistenceImpl.java:1936)
at com.liferay.portlet.documentlibrary.service.impl.DLContentLocalServiceImpl.getContent(DLContentLocalServiceImpl.java:147)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:153)
at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:85)
at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:58)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:127)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:127)
at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:173)
at com.sun.proxy.$Proxy271.getContent(Unknown Source)
at com.liferay.portal.store.db.DBStore.getFileAsStream(DBStore.java:192)
2.) I currently have a custom micro service or bundle that runs as a JAX-RS service that fetches document and return the list of documents to the consumer. This service uses the following liferay document API as follows:
4.) If we move to DBStore, can the DBA perform replication on lportal schema from Primary to DR database ? As we are currently replicating one custom table, can we replicate the document library tables?. If yes, do you know the tables to replicate?
However, I have a couple of questions as define as follows:1.) I have tested in one of my development server by using DBStore as suggested from this page https://portal.liferay.dev/docs/7-2/deploy/-/knowledge_base/d/using-the-dbstore. I have manually imported, application logo location and two documents successfully using the document library uploader and look into the DLContent which I am assuming the documents are stored as a BLOB data in the data_ column. However, when I use the Import/export portlet to import a LAR file which has all 188 documents I receive the following exception shown below in bold. Do you know what the cause of this exception? Can the Import/Export portlet work for documents stored in the DBStore (liferay database)? Is this exception due to fact that its looking for document stored in the DBStore (DLContent table)? How would I migrate all my documents or assets to the DBStore (liferay database)? Caused by: com.liferay.document.library.kernel.exception.NoSuchContentException: No DLContent exists with the key {companyId=20116, repositoryId=20147, path=20, version=1.0}
at com.liferay.portlet.documentlibrary.service.persistence.impl.DLContentPersistenceImpl.findByC_R_P_V(DLContentPersistenceImpl.java:1936)
at com.liferay.portlet.documentlibrary.service.impl.DLContentLocalServiceImpl.getContent(DLContentLocalServiceImpl.java:147)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:153)
at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:85)
at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:58)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:127)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:127)
at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:173)
at com.sun.proxy.$Proxy271.getContent(Unknown Source)
at com.liferay.portal.store.db.DBStore.getFileAsStream(DBStore.java:192)
2.) I currently have a custom micro service or bundle that runs as a JAX-RS service that fetches document and return the list of documents to the consumer. This service uses the following liferay document API as follows:
- DLFileEntryLocalServiceUtil.getDLFileEntries,
- DLFileEntryLocalServiceUtil.fetchFileEntry,
- DLFileEntryLocalServiceUtil.getFileAsStream,
- DLFileEntryLocalServiceUtil.getFileEntry
4.) If we move to DBStore, can the DBA perform replication on lportal schema from Primary to DR database ? As we are currently replicating one custom table, can we replicate the document library tables?. If yes, do you know the tables to replicate?
Hm - some of this is hard to remote-diagnose.
First of all: As far as I remember 7.0 GA3 didn't even contain clustering code - but as it's not the latest GA in that series, you should consider upgrading to the latest GA release in that major series shortly (to make sure you're not running into bugs that have long been fixed), and to a release that still gets upgrades (e.g. 7.2.x) afterwards.
1) Does the exception happen during Ex- or Import?
2) I expect that API to be stable, no matter what storage is used. Note that you're using the services without any permission checking. It's probably what you want for replication purposes - but make sure you know who's calling your JAX-RS service, and that this is what you actually want
3) If you're not replicating live, you're basically talking about a backup/restore scenario. Nobody wants backups, but everybody likes to be able to recover from a data loss situation. I'd not import with LAR files, but just set up proper backup/restore procedures.
It's my principle to state that you're only allowed to call something a backup, if you've recently demonstrated, that you're able to restore to a completely new and untouched system.
4) I won't go into naming individual tables: You'll need the binary content, and the metadata - e.g. name, association with sites, permissions, users, etc. Keep in mind that a proper backup might need to include the search index, unless you're dealing with data that can quickly be reindexed during the recovery time. I'm mentioning that here, because it's data that's required on the other side and not even stored within the schema.
First of all: As far as I remember 7.0 GA3 didn't even contain clustering code - but as it's not the latest GA in that series, you should consider upgrading to the latest GA release in that major series shortly (to make sure you're not running into bugs that have long been fixed), and to a release that still gets upgrades (e.g. 7.2.x) afterwards.
1) Does the exception happen during Ex- or Import?
2) I expect that API to be stable, no matter what storage is used. Note that you're using the services without any permission checking. It's probably what you want for replication purposes - but make sure you know who's calling your JAX-RS service, and that this is what you actually want
3) If you're not replicating live, you're basically talking about a backup/restore scenario. Nobody wants backups, but everybody likes to be able to recover from a data loss situation. I'd not import with LAR files, but just set up proper backup/restore procedures.
It's my principle to state that you're only allowed to call something a backup, if you've recently demonstrated, that you're able to restore to a completely new and untouched system.
4) I won't go into naming individual tables: You'll need the binary content, and the metadata - e.g. name, association with sites, permissions, users, etc. Keep in mind that a proper backup might need to include the search index, unless you're dealing with data that can quickly be reindexed during the recovery time. I'm mentioning that here, because it's data that's required on the other side and not even stored within the schema.
1) Does the exception happen during Ex- or Import? The exception occurs during Import.
2.) Thanks. Our consumers are internal but will note permission checker for the next release.
3.) If you're not replicating live, you're basically talking about a backup/restore scenario. Nobody wants backups, but everybody likes to be able to recover from a data loss situation. I'd not import with LAR files, but just set up proper backup/restore procedures.
It's my principle to state that you're only allowed to call something a backup, if you've recently demonstrated, that you're able to restore to a completely new and untouched system. Just to be clear, as the requirement scope is only to copy the documents to another instance not the. Is there documentation or a procedure on how to to backup/restore documents in Liferay , as I have been using the Import/Export portlet to do it manually.
4.) I won't go into naming individual tables: You'll need the binary content, and the metadata - e.g. name, association with sites, permissions, users, etc. Keep in mind that a proper backup might need to include the search index, unless you're dealing with data that can quickly be reindexed during the recovery time. I'm mentioning that here, because it's data that's required on the other side and not even stored within the schema.
In summary, in order to do nightly backups or copy of the documents only to a DR server, are you recommending to go with storing the documents in DB versus creating a custom document handler to do the import/export?
Thanks
Kevin
2.) Thanks. Our consumers are internal but will note permission checker for the next release.
3.) If you're not replicating live, you're basically talking about a backup/restore scenario. Nobody wants backups, but everybody likes to be able to recover from a data loss situation. I'd not import with LAR files, but just set up proper backup/restore procedures.
It's my principle to state that you're only allowed to call something a backup, if you've recently demonstrated, that you're able to restore to a completely new and untouched system. Just to be clear, as the requirement scope is only to copy the documents to another instance not the. Is there documentation or a procedure on how to to backup/restore documents in Liferay , as I have been using the Import/Export portlet to do it manually.
4.) I won't go into naming individual tables: You'll need the binary content, and the metadata - e.g. name, association with sites, permissions, users, etc. Keep in mind that a proper backup might need to include the search index, unless you're dealing with data that can quickly be reindexed during the recovery time. I'm mentioning that here, because it's data that's required on the other side and not even stored within the schema.
In summary, in order to do nightly backups or copy of the documents only to a DR server, are you recommending to go with storing the documents in DB versus creating a custom document handler to do the import/export?
Thanks
Kevin
<p>Hi Olaf, I have decided to use the database itself and I do see the application is working after I migrated the data using the dbstore and setting portal-ext.properties. Also, tested the webservice to fetch the documents and it does work so no code changes (good thing
. I will setup replication on the following tables dlcontent,dlfileentry,dlfilerank,dlfileshortcut,dlfileversion,dlfolder. Also, most importantly I was able to use the Import/Export portlet to import the data.</p>

Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™