+ protected void backupDataStore(final FileObject targetDatastore) {
+ try {
+ targetDatastore.createFolder();
+ final FileObject sourceDataStore = fileSystemManager
+ .resolveFile(sourceDatastore);
+ if (log.isDebugEnabled())
+ log.debug("Backup " + sourceDatastore);
+ targetDatastore.copyFrom(sourceDataStore, new FileSelector() {
+ public boolean traverseDescendents(FileSelectInfo fileInfo)
+ throws Exception {
+ return true;
+ }
+
+ public boolean includeFile(FileSelectInfo fileInfo)
+ throws Exception {
+ String relativeName = fileInfo
+ .getFile()
+ .getName()
+ .getPath()
+ .substring(
+ sourceDataStore.getName().getPath()
+ .length());
+ FileObject target = targetDatastore
+ .resolveFile(relativeName);
+ if (target.exists()) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+ });
+ if (log.isDebugEnabled())
+ log.debug("Backed-up " + sourceDatastore);
+ } catch (FileSystemException e) {
+ throw new SlcException("Cannot backup datastore", e);
+ }
+ }
+