November 2, 20196 yr Hello. I want to have a script that runs every night and simply outputs all the files/folders on target drives specified to a text file on a share somewhere outside of unraid. Why you may ask? In the highly unlikely scenario of actual data loss i want to be able to see what was lost after the fact... It's very difficult to keep track of what data is on which drive when you have a large array and once data is gone how are you suppose to know what you lost? Knowing what data is lost mitigates the pain a lot. Anyone know how i could go about doing this? Edited November 2, 20196 yr by je82
November 2, 20196 yr Next look through existing scripts shared, if none match then ask if anyone has one.
November 2, 20196 yr Author very nice thanks, looks like someone already done something like this, "Catalog Drive Contents"
September 19, 20241 yr Here is a link to the "Catalog Drive Contents" script je82 probably found, for future googlers. I improved it by letting it delete old lists. Here is the full script: #!/bin/sh #description=Creates an inventory tree of all mounted disks (not cache) and deletes txt files older than x days #arrayStarted=true SAVEPATH=/boot/config/indexTree RETENTION_DAYS=30 # Set the number of days to keep files # Create inventory trees for all mounted disks for f in /mnt/disk* do echo "Scanning tree for $f" mkdir -p $SAVEPATH/$(basename $f) tree -o $SAVEPATH/$(basename $f)/$(date +%Y%m%d).txt "$f" done # Delete .txt files older than RETENTION_DAYS echo "Deleting .txt files older than $RETENTION_DAYS days..." find $SAVEPATH -name "*.txt" -type f -mtime +$RETENTION_DAYS -exec rm -f {} \; echo "indexTree complete!" exit 0
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.