AniNIX::Aether \\ Backup and Failsafe System
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

84 lines
3.4 KiB

SHELL := /bin/bash
BACKUPDIR := /usr/local/backup
client: user aether.bash
cp aether.bash /home/aether/aether.bash
/home/aether/aether.bash
sudo -u aether crontab -l > /tmp/cronie
grep aether.bash /tmp/cronie || echo '0 1 * * * /home/aether/aether.bash &>> /var/log/aether.log' >> /tmp/cronie
sudo -u aether crontab /tmp/cronie
rm /tmp/cronie
touch /var/log/aether.log
chown aether:aether /var/log/aether.log
make checkperm
compile:
@echo Nothing to do
install: compile
@echo You must specify client or server in a call to make.
server: keys scripts user ./aether-gen.bash ./aether.pub ./server-backup
bash ./aether-gen.bash
cp ./aether.pub /home/aether/.ssh/authorized_keys
cp ./aether-gen.bash /root/bin/aether-gen.bash
mkdir -p /usr/local/etc/Aether/backup-entries
touch /usr/local/etc/Aether/nodeslist
mkdir -p ${BACKUPDIR};
make checkperm
@echo You have the files. Add aether-gen.bash and server-backup to root\'s crontab.
@echo Mark services to be backed up by adding a file from examples/ to /usr/local/etc/Aether/backup-entries
@echo Track client nodes in /usr/local/etc/Aether/nodeslist
user: aether make-user.bash
/bin/bash ./make-user.bash
node-command:
@echo USE THE FOLLOWING COMMANDS TO SET UP A NODE.
@echo -ne 'git clone https://aninix.net/foundation/Aether;'
@echo
@echo -ne 'cd Aether; cat > aether # Paste the private key'
@echo
@echo -ne 'make client'
@echo
@echo MAKE SURE TO ADD THE NODE TO /usr/local/etc/Aether/nodes.list
keys:
if [ ! -f ./aether ]; then ssh-keygen -t rsa -P "" -f aether; fi
scripts: ./server-backup ./remote-backup
cp ./server-backup /root/bin
cp ./remote-backup /root/bin
make checkperm
reverse:
if [ -f /root/bin/server-backup ]; then cp /root/bin/server-backup .; fi
if [ -f /root/bin/remote-backup ]; then cp /root/bin/remote-backup .; fi
if [ -f /root/bin/aether-gen.bash ]; then cp /root/bin/aether-gen.bash .; fi
if [ -f /home/aether/aether.bash ]; then cp /home/aether/aether.bash .; fi
diff:
if [ -f /root/bin/server-backup ]; then diff ./server-backup /root/bin/server-backup; fi
if [ -f /root/bin/remote-backup ]; then diff ./remote-backup /root/bin/remote-backup; fi
if [ -f /root/bin/aether-gen.bash ]; then diff ./aether-gen.bash /root/bin/aether-gen.bash; fi
if [ -f /home/aether/aether.bash ]; then diff ./aether.bash /home/aether/aether.bash; fi
checkperm:
id aether;
if [ -d /home/aether ]; then chmod 0600 /home/aether/.ssh/authorized_keys; chmod 0700 /home/aether/.ssh /home/aether; chown -R aether:aether /home/aether; fi
if [ -f /root/bin/remote-backup ]; then chmod 0700 /root/bin/remote-backup; chown root:root /root/bin/remote-backup; fi
if [ -f /root/bin/server-backup ]; then chmod 0700 /root/bin/server-backup; chown root:root /root/bin/server-backup; fi
if [ -d /usr/local/etc/Aether ]; then chmod -R 0700 /usr/local/etc/Aether; chown -R aether:aether /usr/local/etc/Aether; fi
if [ -d ${BACKUPDIR} ]; then chmod 0770 ${BACKUPDIR}; chown postgres:root ${BACKUPDIR}; fi
if [ -f /var/log/aether.log ]; then chown aether:aether /var/log/aether.log; chmod 0750 /var/log/aether.log; fi
clean:
@bash -c 'printf "This will irreversibly destroy all backups. Confirm? [YES/no] " ; read answer; [ "$$answer" == "YES" ] && exit 0; exit 1'
for i in `ls /home/aether/aether*`; do shred $$i; done
rm -Rf /home/aether
userdel aether
find /usr/local/backup -type f -exec shred {} \;
rm -Rf /usr/local/backup; fi
test:
python3 -m pytest