Skip to content

Instantly share code, notes, and snippets.

@yarwelp
Last active August 29, 2015 14:22
Show Gist options
  • Save yarwelp/248a90bd42de0798d847 to your computer and use it in GitHub Desktop.
Save yarwelp/248a90bd42de0798d847 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Made by erikano for use on FreeBSD 10.1
#
# This script assumes that a previous backup exists
# with the expected file name format.
#
# You need to change some stuff if you want to use this.
#
# * Script is using hard-coded directory names and such.
#
# * No effort has been made to make this script portable.
# E.g. GNU stat does not understand what we're saying here.
# Though this script will detect files with changes to ownership/permissions
# thanks to checking ctime, one might argue that it's inefficient to backup
# the whole file again for inode changes only. That is true, but so is
# the fact that backing up a whole file again for as little as
# a single byte change is almost as inefficient. This is a design decission and
# I'm sticking with it until the effect of this choice forces me
# to do something about it.
export TZ=Europe/Oslo
cd /usr/local/www/
cmp=$( find ~/backup/ -name www-erikano-net-archive\* \
-exec stat -f "%Sm %N" -t "%Y-%m-%d %H:%M" {} \; \
| sort -n -r \
| head -n1 )
find net.erikano.www/ ! -path net.erikano.www/ \
-newer "$( echo $cmp | cut -d' ' -f3- )" \
-or -cnewer "$( echo $cmp | cut -d' ' -f3- )" \
| cmp -s /dev/null -
if [ $? -ne 0 ] ; then
tar \
--exclude-from ./net.erikano.www/.backup-exclude \
--newer "$( echo $cmp | cut -d' ' -f1-2 )" \
-cvf ~/backup/www-erikano-net-archive-incr-$( date +%Y-%m-%dT%H%M%S%z).tar \
net.erikano.www/
fi
@yarwelp
Copy link
Author

yarwelp commented Jun 13, 2015

(Contents of this comment moved inline of script.)

@yarwelp
Copy link
Author

yarwelp commented Jun 14, 2015

Created a repository for what'll replace this. https://github.com/erikano/binc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment