#!/bin/zsh if [[ $EUID != 0 ]]; then echo "This script must be run as root" 1>&2 exit 1 fi CONFIGS=("zee-home" "zee-home-1") ACTIVE="" CURRENT="" for i in {1..$#CONFIGS} do (/Users/zee/Stuff/s3sync/s3cmd.rb -s list technocore:$CONFIGS[$i]/.active | grep .active) > /dev/null 2>&1 if [[ $? == 0 ]]; then ACTIVE=$CONFIGS[$i] CURRENT=$CONFIGS[$(( $i % $#CONFIGS + 1 ))] break fi done if [[ $ACTIVE == "" ]]; then echo "Couldn't find active backup, something's wrong." 1>&2 exit 1 fi echo "Currently active backup: $ACTIVE, backing up to $CURRENT" /Users/zee/Stuff/s3sync/s3sync.rb -s --progress -r /Volumes/Backup/Backups.backupdb/discordia/Latest/discordia/Users/zee/zee.sparsebundle technocore:$CURRENT && /Users/zee/Stuff/s3sync/s3cmd.rb -s put technocore:$CURRENT/.active /dev/null && /Users/zee/Stuff/s3sync/s3cmd.rb -s delete technocore:$ACTIVE/.active