Skip to content

Instantly share code, notes, and snippets.

@ukdave
Created December 9, 2015 14:55
Show Gist options
  • Save ukdave/4dc1c5ec92354b513300 to your computer and use it in GitHub Desktop.
Save ukdave/4dc1c5ec92354b513300 to your computer and use it in GitHub Desktop.
#!/bin/bash
NEXUS_STORAGE_DIR=/opt/sonatype-work/nexus/storage
DIFF_DIR=/home/console/nexus-diffs
TSTAMP=`date +"%Y-%m-%d_%H-%M"`
if [ ! -f ${DIFF_DIR}/filelist_latest.txt ]; then
touch ${DIFF_DIR}/filelist_0000-00-00_00-00.txt
ln -s ${DIFF_DIR}/filelist_0000-00-00_00-00.txt ${DIFF_DIR}/filelist_latest.txt
fi
pushd ${NEXUS_STORAGE_DIR}
find {central,jcenter} -type f -regextype posix-extended ! -regex ".*\.(index|meta|nexus).*" > ${DIFF_DIR}/filelist_${TSTAMP}.txt
popd
diff ${DIFF_DIR}/filelist_latest.txt ${DIFF_DIR}/filelist_${TSTAMP}.txt > ${DIFF_DIR}/diff.txt
egrep "^> .*$" ${DIFF_DIR}/diff.txt | awk '{print $2}' > ${DIFF_DIR}/diff-added.txt
tar -czvf ${DIFF_DIR}/diff.tgz -C ${NEXUS_STORAGE_DIR} -T diff-added.txt
rm ${DIFF_DIR}/filelist_latest.txt
ln -s ${DIFF_DIR}/filelist_${TSTAMP}.txt ${DIFF_DIR}/filelist_latest.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment