Created
February 10, 2016 21:43
-
-
Save m87carlson/52ff9bf102ceca0dcf77 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/root/bin | |
usage() | |
{ | |
cat << EOF | |
Usage: $0 /zpool/filesystem 90d | |
This script will send list of files using find and rsync over | |
N days | |
EOF | |
} | |
if [[ -z $1 || -z $2 ]] | |
then | |
usage | |
exit 1 | |
fi | |
pool=$1 | |
retention_period=$2 | |
remote_pool=`echo $1 |awk -F/ '{print $NF}'` | |
destination="/data/`hostname -s`-backup/$remote_pool" | |
host="zfs-3" | |
echo "DEBUG:" | |
echo "pool=${pool}" | |
echo "remote_pool=${remote_pool}" | |
echo "destination=${destination}" | |
echo "host=${host}" | |
cd $pool | |
find . -type f -mtime -${retention_period} -print0 | rsync -av --progress -t --files-from=- --from0 ./ ${host}:${destination} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment