Skip to content

Instantly share code, notes, and snippets.

@kbsriram kbsriram/backup-wiki.sh Secret
Created May 11, 2014

Embed
What would you like to do?
current indiewebcamp wiki stuff.
#!/bin/bash
error_exit ()
{
echo "$1"
exit 1
}
date
wm=/Users/kbs/personal/indiewebcamp/wget-mirror
wget=/usr/local/bin/wget
cd ${wm} || error_exit "bad wget-mirror"
${wget} --quiet --execute robots=off --no-parent --mirror https://indiewebcamp.com/wiki/backup/data/ || error_exit "failed wget"
gd=/Users/kbs/personal/indiewebcamp/wiki-archive
wt=/Users/kbs/personal/indiewebcamp/wget-mirror/indiewebcamp.com/wiki/backup/data
git="/usr/local/bin/git --git-dir=${gd} --work-tree=${wt}"
changes=`${git} ls-files -m -o --exclude-standard`
if [ -z "${changes}" ]
then
echo "no changes"
exit 0
fi
${git} add -A ${wt} || error_exit "unable to git-add"
${git} commit -m "wiki-backup `date`" || error_exit "unable to git-commit"
${git} push -u origin master || error_exit "unable to git push"
# incremental update 3 days of week.
45 10 * * 1,3,5 /Users/kbs/personal/indiewebcamp/backup-wiki.sh > /Users/kbs/personal/indiewebcamp/backup.log 2>&1
# once a month, force delete wget mirror.
45 9 1 * * /Users/kbs/personal/indiewebcamp/nuke-wget-mirror.sh > /Users/kbs/personal/indiewebcamp/nuke.log 2>&1
#!/bin/bash
error_exit ()
{
echo "$1"
exit 1
}
date
wm=/Users/kbs/personal/indiewebcamp/wget-mirror
cd ${wm} || error_exit "bad wget-mirror"
rm -rf indiewebcamp.com
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.