Skip to content

Instantly share code, notes, and snippets.

@robacarp
Last active December 17, 2015 01:29
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 robacarp/e0e3040a929aac6b6a5d to your computer and use it in GitHub Desktop.
Save robacarp/e0e3040a929aac6b6a5d to your computer and use it in GitHub Desktop.
#!/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