Last active
December 12, 2015 04:09
-
-
Save wrought/4712720 to your computer and use it in GitHub Desktop.
Localwiki backup script based on https://guide.localwiki.org/Backup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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