Skip to content

Instantly share code, notes, and snippets.

@wrought
Last active December 12, 2015 04:09
Show Gist options
  • Save wrought/4712720 to your computer and use it in GitHub Desktop.
Save wrought/4712720 to your computer and use it in GitHub Desktop.
Localwiki backup script based on https://guide.localwiki.org/Backup
#!/bin/bash
timestamp=`date -u +%Y-%m-%d_%H-%M-%S`
tempdir=~/backups/localwiki-backup-$timestamp
# set stage
mkdir $tempdir -p # make (-p) parent directories as needed
# do the dirty work
cp -r /usr/share/localwiki/ $tempdir/usr.share.localwiki/
sudo -u postgres pg_dump -U postgres localwiki > $tempdir/localwiki.sql
cp -r /etc/apache2/sites-enabled/ $tempdir/etc.apache2.sites-enabled # change to sites-available if you use standard symlinks
# wrap it up
tar --verify -zcf $tempdir.tar.gz $tempdir
# ignore issue "tar: Removing leading `/' from member names"
# we don't need absolute file names (with -P), more info:
# http://www.gnu.org/software/tar/manual/html_chapter/Choosing.html#SEC118
# clean
rm -rf $tempdir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment