Skip to content

Instantly share code, notes, and snippets.

@ironicbadger
Last active December 23, 2015 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ironicbadger/bc8da95280a4e8324308 to your computer and use it in GitHub Desktop.
Save ironicbadger/bc8da95280a4e8324308 to your computer and use it in GitHub Desktop.
#!/bin/bash
rsync=/usr/bin/rsync
ssh=/usr/bin/ssh
sshkey=/home/alex/.ssh/id_rsa.pub
omega_user=root
omega_host=omega
omega_backup_path=/volume1/omega/backups
epsilon_storage=/mnt/storage
# backup paths
declare -a backup_from_epsilon_root=("/opt/appdata")
declare -a backup_from_storage=("photos" \
"backups/btSyncDad" \
"backups/btSyncMum" \
"music/classical" \
"music/flac" \
"backups/dashcam" \
"backups/appdata.backup")
# backup from / paths to /mnt/storage
for item in "${backup_from_epsilon_root[@]}"
do
if [[ $item == "/opt/appdata" ]]; then
$rsync -avzP \
--delete \
--exclude=/opt/appdata/nzbget/downloads \
$item \
$epsilon_storage/backups/appdata.backup
fi
done
# backup to omega from /mnt/storage
for item in "${backup_from_storage[@]}"
do
fullpath="$epsilon_storage/$item"
if [[ $item == *"backups/"* ]]; then
item="${item##*/}"
fi
$rsync -avzP -e $ssh -i $sshkey $fullpath/ $omega_user@$omega_host:$omega_backup_path/$item/
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment