#!/bin/sh

#copy this script to your backup directory, e.g., /data/backups/

#set where from/to mirror monthly backups
MONTHLY_FROM="/data/backups/"
MONTHLY_TO="scribe@crosswire.org:/backup/ntvmr/"

# IMAGES, which image resolutions to backup is from ./backupdirs
# be sure to copy backupdirs and excludedirs files to where this
# script lives.
# Currently, we're only backing up webfriendly, but maybe we'll
# backup full if we ever get these integrated into the VMR.
# the others can be regenerated if necessary
IMAGES_FROM="/data/images/"
IMAGES_TO="scribe@crosswire.org:/backup/ntvmr/images/"


# DELETE - USE TO DELETE FILES ON THE RECEIVER IF THEY DON'T EXIST ON THE SENDER
#OPTIONS="--delete $OPTIONS"

# Dry Run
#OPTIONS="-n $OPTIONS"

# Recursive (needed with --files-from)
OPTIONS="-r $OPTIONS"

# Archive
OPTIONS="-a $OPTIONS"

# treat symlinks to dirs on receiver as dir
#OPTIONS="--keep-dirlinks $OPTIONS"

#OPTIONS="--copy-unsafe-links $OPTIONS"

# Verbose
OPTIONS="-v $OPTIONS"

# Preserve hard links
OPTIONS="-H $OPTIONS"

# Handle sparse files efficiently
OPTIONS="-S $OPTIONS"


# Update - skip files that are newer on the receiver
OPTIONS="-u $OPTIONS"

# Compress data during transfer
#OPTIONS="-z $OPTIONS"

# Show progress and keep partially tranfered files for later resume
OPTIONS="--progress --partial $OPTIONS"


#Latest Monthly
LATEST=`ls -t monthly-backup-*.tar.gz|head -1`

rsync $OPTIONS $MONTHLY_FROM/$LATEST $MONTHLY_TO

# List of files
OPTIONS="--files-from=`dirname $0`/backupdirs $OPTIONS"
OPTIONS="--exclude-from=`dirname $0`/excludedirs $OPTIONS"

rsync $OPTIONS $IMAGES_FROM $IMAGES_TO
