mirror of https://github.com/trapexit/mergerfs.git
				
				
			
			You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							37 lines
						
					
					
						
							878 B
						
					
					
				
			
		
		
		
			
			
			
		
		
	
	
							37 lines
						
					
					
						
							878 B
						
					
					
				| #!/usr/bin/env sh | |
|  | |
| if [ $# != 3 ]; then | |
|     echo "usage: $0 <cache-fs> <base-pool> <percentage>" | |
|     exit 1 | |
| fi | |
| 
 | |
| CACHEFS="${1}" | |
| BASEPOOL="${2}" | |
| PERCENTAGE=${3} | |
| 
 | |
| set -o errexit | |
| while [ $(df "${CACHE}" | tail -n1 | awk '{print $5}' | cut -d'%' -f1) -gt ${PERCENTAGE} ] | |
| do | |
|     # Find the file with the oldest access time | |
|     FILE=$(find "${CACHE}" -type f -printf '%A@ %P\n' | \ | |
|                sort | \ | |
|                head -n 1 | \ | |
|                cut -d' ' -f2-) | |
|     # If no file found, exit | |
|     test -n "${FILE}" || exit 0 | |
|     # Move file | |
|     rsync \ | |
|         --archive \ | |
|         --acls \ | |
|         --xattrs \ | |
|         --atimes \ | |
|         --hard-links \ | |
|         --one-file-system \ | |
|         --quiet \ | |
|         --preallocate \ | |
|         --remove-source-files \ | |
|         --relative \ | |
|         --log-file=/tmp/mergerfs-cache-rsync.log \ | |
|         "${CACHE}/./${FILE}" \ | |
|         "${BACKING}/" | |
| done
 |