Skip to content

Instantly share code, notes, and snippets.

@robacarp robacarp/backup.sh Secret
Last active Dec 17, 2015

Embed
What would you like to do?
#!/bin/bash
#remote backup host
host=robert@192.168.55.22
#directory to store backups on $host
dir=/mnt/TB/basilius
#the name of todays backup folder.....
name=`date "+%Y-%m-%d-%H-%M"`
#most recent folder modified in the remote backup store
prev_dirs=$(ssh $host "/bin/bash -c \"ls -At $dir\"" | head -n3)
#setup the hardlinking for the remote system
hardlinks=""
for file in $prev_dirs; do
hardlinks="$hardlinks --link-dest=$dir/$file"
done
# #archive implies:
# --recursive \
# --links \
# --perms \
# --times \
# --owner \
# --group \
# --device \
# --specials \
# the old style....
# --backup --backup-dir=.backup/$date --delete-after \
rsync --human-readable --progress --stats \
--filter='merge rsync-filters.txt' \
--archive \
$hardlinks \
--hard-links \
--compress \
~/ $host:$dir/$name
echo Backup to $host:$dir/$name finished.
#mark the backup as completed
ssh $host "/bin/bash -c \"touch $dir/$name/.completed; ln -sf $dir/$name $dir/last-backup\""
- .dropbox/*
- *.app
- Library/**
- .Trash/**
- .cpan/**
- .rvm/**
- */Documents/Virtual Machines.localized**
- Documents/Adobe/Premiere\ Pro*
- *.DS_Store
+ */.git/config
+ */.git/FETCH_HEAD
+ */.git/HEAD
+ */.git/ORIG_HEAD
+ */.git/COMMIT_EDITMSG
- */.git/**
- *.gem
- *.vmdk
- */cache/*
- VirtualBox VMs/**/Snapshots/*
- Documents/eclipse-workspace/*
- .sbt/*
- Sites/davinci/uploads/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.