From 0b7c6305e17e9afe8e80eb9a33b3d38eab39afdd Mon Sep 17 00:00:00 2001 From: dev Date: Wed, 10 Aug 2016 12:38:26 -0500 Subject: [PATCH] Fixes to control backup size and back up the right things. Backups encrypted and labeled as such. --- aether-gen.bash | 17 +++-------------- aether.bash | 2 +- server-backup | 47 +++++++++++++++++++++++++++++------------------ 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/aether-gen.bash b/aether-gen.bash index 36cb321..1b74b54 100755 --- a/aether-gen.bash +++ b/aether-gen.bash @@ -2,25 +2,14 @@ export LOGFILE="/var/log/aether-gen.log" +/usr/local/src/Aether/server-backup + cd /home/aether date >> $LOGFILE -mkdir -p target - -# Get a list of what's in Yggdrasil, in case we need to go hunting. -echo "Getting file list..." -find /srv/yggdrasil/ > target/Yggdrasil_file_list.txt - -# Copy the nonrecoverable data to the target location. -rsync -azl --delete-after /usr/local/src/ target/src/ -rsync -azl --delete-after /usr/local/etc/ target/etc/ -rsync -azl --delete-after /usr/local/backup target/ - -date > target/last-updated - echo Creating and compressing archive... -tar cvf aether.tar target +tar cvf aether.tar /usr/local/backup gzip -f aether.tar echo Encrypting archive diff --git a/aether.bash b/aether.bash index 4eaf753..016c812 100755 --- a/aether.bash +++ b/aether.bash @@ -13,5 +13,5 @@ fi export TARGET="aether-"$(date +%F)".enc" printf "get /aether/aether.enc %s\nbye\n" $TARGET | sftp -o IdentityFile=./.ssh/aether aether@aninix.net -echo "Failsafe populated. Today\'s was saved to "$TARGET +echo "Aether copy populated. Today\'s was saved to "$TARGET exit diff --git a/server-backup b/server-backup index c9d0318..46f355c 100755 --- a/server-backup +++ b/server-backup @@ -1,10 +1,13 @@ #!/bin/bash export BACKUPDIR="/usr/local/backup" +export BACKUPCMD="rsync -avzl --delete-after"; ## Backup small development ## +chown postgres:root "$BACKUPDIR" +chmod 0770 "$BACKUPDIR" -rsync -avzl --delete-after /root/bin/ "$BACKUPDIR"/root/bin/ +$BACKUPCMD /root/bin/ "$BACKUPDIR"/root/bin/ ## Backup configuration ## cp -r /etc/skel "$BACKUPDIR" @@ -14,37 +17,45 @@ cp /etc/vimrc "$BACKUPDIR"/vimrc ## Backup the good servers ## ### SSHD ### -rsync -avzl --delete-after /etc/ssh "$BACKUPDIR"/ssh +$BACKUPCMD /etc/ssh "$BACKUPDIR"/ssh ### Lighttpd ### -rsync -avzl --delete-after /etc/lighttpd/ "$BACKUPDIR"/lighttpd -rsync -avzl --delete-after /srv/http/ "$BACKUPDIR"/http/ +$BACKUPCMD /etc/lighttpd/ "$BACKUPDIR"/lighttpd +$BACKUPCMD /srv/http/ "$BACKUPDIR"/http/ ### Cron ### crontab -l > "$BACKUPDIR"/$(whoami)-crontab ### IRC Server ### -rsync -avzl --delete-after /etc/unrealircd/ "$BACKUPDIR"/unrealircd -rsync -avzl --delete-after /etc/anope/ "$BACKUPDIR"/anope -# TODO add backup +$BACKUPCMD /etc/unrealircd/ "$BACKUPDIR"/unrealircd +$BACKUPCMD /etc/anope/ "$BACKUPDIR"/anope +cp /opt/anope/data/anope.db "$BACKUPDIR" -### TheRaven ### -# Added under Bazaar source - -### Bazaar ### -rsync -avzl --delete-after /srv/bazaar/ "$BACKUPDIR"/bazaar -rsync -avzl --delete-after /usr/local/src/ "$BACKUPDIR"/src -rsync -avzl --delete-after /usr/local/etc/ "$BACKUPDIR"/usr-local-etc +### Foundation ### +$BACKUPCMD /srv/foundation/ "$BACKUPDIR"/Foundation +$BACKUPCMD /usr/local/etc/ "$BACKUPDIR"/usr-local-etc ### Wiki ### -rsync -avzl --delete-after /usr/share/webapps/mediawiki/LocalSettings.php "$BACKUPDIR"/mediawiki-localsettings.php +$BACKUPCMD /usr/share/webapps/mediawiki/LocalSettings.php "$BACKUPDIR"/mediawiki-localsettings.php +# Databases backed up by Grimoire ### Singularity ### -# Backed up by postgres backup +cp /usr/share/webapps/tt-rss/config.php "$BACKUPDIR"/singularity-config.php +# Databases backed up by Grimoire -### PostgreSQL ### -# TODO +### 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