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"
No comments:
Post a Comment