Sunday, December 11, 2011

How to transfer file from one CRX to other modified after certain date using CURL in CQ / WEM / CRX

Use case: You want to copy all files modified after certain date and time from one instance to another. this is also use ful for migration projects.

Solution You can use following unix script to do that (Example refer /var/dam) change it based on your requirement

Approach: Initially I thought, I will build list of all the pages and then use vlt rcp. But problem with this approach is, on destination you might not have Path (Subfolder) and in that case you will get path not found exception using vlt. Instead you can use reciprocal approach and find all pages created "before" certain date and then exclude them (Good for smaller size folder, not good for huge data) from all vlt copy from parent folder (Make sure that that exist in destination).

Prerequisite make sure that you have VLT configured. Please see http://dev.day.com/docs/en/crx/current/how_to/how_to_use_the_vlttool.html for that

Solution

#!/bin/bash
# Author: upadhyay.yogesh@gmail.com

# The host and port of the source server
SOURCE="localhost:4504"

# The user credentials on the source server (username:password)
SOURCE_CRED="admin:admin"

# The host and port of the target server
TARGET="localhost:4508"

# The user credentials on the target server (username:password)
TARGET_CRED="admin:admin"

#Filter path
FILTER_PATH="/var/dam"

#Root Path
ROOT_PATH="/var/dam"

FILTER_COUNT=0

SPACE=" "
#############################################################################

#Query to get all files uploaded after certain date
#echo "Creating path list"
ALL_PATHS=`curl -s -u $SOURCE_CRED "$SOURCE/bin/querybuilder.json?path=$FILTER_PATH&type=nt:file&&p.limit=-1&daterange.property=jcr:created&daterange.upperBound=2011-11-11&daterange.upperOperation=<&orderby=jcr:created&orderby.sort=desc" | tr ",[" "\n" | grep path | awk -F \" '{print $4 "\n"}'`
echo "$ALL_PATHS"
for SINGLE_PATH in $ALL_PATHS
do
EXCLUDE=${EXCLUDE}${SINGLE_PATH}${SPACE}
done
vlt rcp -e '$EXCLUDE' -r http://$SOURCE_CRED@$SOURCE/crx/-/jcr:root$ROOT_PATH http://$TARGET_CRED@$TARGET/crx/-/jcr:root$ROOT_PATH
echo "vlt rcp -e \"$EXCLUDE\" -r http://$SOURCE_CRED@$SOURCE/crx/-/jcr:root$ROOT_PATH http://$TARGET_CRED@$TARGET/crx/-/jcr:root$ROOT_PATH"

1 comment:

  1. IEEE Project Domain management in software engineering is distinct from traditional project deveopment in that software projects have a unique lifecycle process that requires multiple rounds of testing, updating, and faculty feedback. A IEEE Domain project Final Year Projects for CSE system development life cycle is essentially a phased project model that defines the organizational constraints of a large-scale systems project. The methods used in a IEEE DOmain Project systems development life cycle strategy Project Centers in Chennai provide clearly defined phases of work to plan, design, test, deploy, and maintain information systems.


    This is enough for me. I want to write software that anyone can use, and virtually everyone who has an internet connected device with a screen can use apps written in JavaScript. JavaScript Training in Chennai JavaScript was used for little more than mouse hover animations and little calculations to make static websites feel more interactive. Let’s assume 90% of all websites using JavaScript use it in a trivial way. That still leaves 150 million substantial JavaScript Training in Chennai JavaScript applications.

    ReplyDelete