#/bin/bash #Script to hardlink duplicate files in folders created by backintime #Bertrand VANDEPORTAELE 2016 #run this script from the folder where you want the results files to be generated #Set this variable to the folder where backtime saves the files BASE_DIR=/media/bvandepo/HD3TO14/savebackintime/backintime/rapid/bvandepo/1/ #To only detect the duplicates without applying the hardlink, uncomment the following line #PARAM_TEST="-dryrun true" # http://www.thegeekstuff.com/2013/05/date-command-examples DATE_VAL=`date +%F%T` echo date: "${DATE_VAL}" RESULT_FILE="rdfind_result_${DATE_VAL}.txt" echo result file: "${RESULT_FILE}" echo ---------------------------------------------------------------------------------------- echo generating folder list... echo ---------------------------------------------------------------------------------------- for i in `ls -d ${BASE_DIR}*` do NEW_DIR="${i}/backup/" if test -z "${LIST_DIR}" then #the variable does not exist yet LIST_DIR="${NEW_DIR}" else LIST_DIR="${LIST_DIR} ${NEW_DIR}" fi done echo ---------------------------------------------------------------------------------------- echo processing the folder list: ${LIST_DIR} echo ---------------------------------------------------------------------------------------- #CMD="sudo rdfind ${LIST_DIR} -makehardlinks true ${PARAM_TEST} -outputname ${RESULT_FILE}" CMD="sudo rdfind ${LIST_DIR} -makehardlinks true ${PARAM_TEST} -outputname ${RESULT_FILE}" echo "generated command: ${CMD}" #execute it eval "$CMD" echo ---------------------------------------------------------------------------------------- echo displaying results... echo ---------------------------------------------------------------------------------------- cat ${RESULT_FILE}