#!/bin/bash # # This script will process each mounted dataVG file system and attempt to # identify duplicate files and replace them with hardlinks # dt=$(date '+%Y%m%d') pth="/var/log/hardlink/${dt}" mkdir -p ${pth} mount | grep dataVG | awk '{print $3}' | sort -r | while read fs do nw=$(date '+%Y%m%d %H:%M:%S') echo "[${nw}] Processing ${fs}" spc=$(df -P ${fs} | tail -1 | awk '{print $2,$3,$4,$5}') ind=$(df -Pi ${fs} | tail -1 | awk '{print $2,$3,$4,$5}') name=$(basename ${fs}) echo "${name} ${spc} ${ind}" > ${pth}/${name} hardlink -v ${fs} &>> ${pth}/${name} spc=$(df -P ${fs} | tail -1 | awk '{print $2,$3,$4,$5}') ind=$(df -Pi ${fs} | tail -1 | awk '{print $2,$3,$4,$5}') echo "${name} ${spc} ${ind}" >> ${pth}/${name} done