Aether/server-backup

65 lines
1.7 KiB
Plaintext
Raw Normal View History

#!/bin/bash
export BACKUPDIR="/usr/local/backup"
export BACKUPCMD="rsync -avzl --delete-after";
2016-11-09 22:29:17 -06:00
if [ ! -d "$BACKUPDIR" ]; then
mkdir "$BACKUPDIR"
fi
## Backup small development ##
chown postgres:root "$BACKUPDIR"
chmod 0770 "$BACKUPDIR"
$BACKUPCMD /root/bin/ "$BACKUPDIR"/root/bin/
## Backup configuration ##
2016-11-09 22:29:17 -06:00
/usr/local/src/MiscScripts/ShadowArch/shadowarch-tar-gen
cp /srv/http/aninix.net/shadowarch.tar "$BACKUPDIR"
## Backup the good servers ##
### SSHD ###
2016-11-09 22:29:17 -06:00
$BACKUPCMD /etc/ssh/ "$BACKUPDIR"/ssh
### Lighttpd ###
$BACKUPCMD /etc/lighttpd/ "$BACKUPDIR"/lighttpd
$BACKUPCMD /srv/http/ "$BACKUPDIR"/http/
### Cron ###
crontab -l > "$BACKUPDIR"/$(whoami)-crontab
### IRC Server ###
$BACKUPCMD /etc/unrealircd/ "$BACKUPDIR"/unrealircd
$BACKUPCMD /etc/anope/ "$BACKUPDIR"/anope
cp /opt/anope/data/anope.db "$BACKUPDIR"
### Foundation ###
$BACKUPCMD /srv/foundation/ "$BACKUPDIR"/Foundation
$BACKUPCMD /usr/local/etc/ "$BACKUPDIR"/usr-local-etc
### Wiki ###
$BACKUPCMD /usr/share/webapps/mediawiki/LocalSettings.php "$BACKUPDIR"/mediawiki-localsettings.php
# Databases backed up by Grimoire
### Singularity ###
cp /usr/share/webapps/tt-rss/config.php "$BACKUPDIR"/singularity-config.php
# Databases backed up by Grimoire
### Grimoire ###
sudo -u postgres pg_dump aninix_wiki > "$BACKUPDIR"/aninix_wiki.psql
sudo -u postgres pg_dump gb_wiki > "$BACKUPDIR"/gb_wiki.psql
sudo -u postgres pg_dump ttrss > "$BACKUPDIR"/ttrss.psql
### Yggdrasil -- File list only for space reasons ###
if [ -x /usr/bin/locate ]; then
locate /srv/yggdrasil > "$BACKUPDIR"/yggdrasil-file-list.txt
else
find /srv/yggdrasil/ > "$BACKUPDIR"/yggdrasil_file_list.txt
fi
# TODO evaluate for other services not covered.
date > /var/log/server-backup.log
date > "$BACKUPDIR"/lastbackup.date