Skip to content
Snippets Groups Projects
Verified Commit d472cd4b authored by David Beniamine's avatar David Beniamine
Browse files

WIP v0

parents
Branches
Tags
No related merge requests found
*.sw?
This diff is collapsed.
Makefile 0 → 100644
# Copyright (C) 2017 Tetras-libre <admin@tetras-libre.fr>
# Author: Beniamine, David <David.Beniamine@tetras-libre.fr>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
NAME=tetras-back
PREFIX=/usr/local
BINDIR=$(PREFIX)/bin
SCRIPTS_DIR=$(PREFIX)/lib/
RULES_DIR=/etc/udev/rules.d
RULE_NAME=50-$(NAME).rules
WEB_PREFIX=/var/www/
APACHE_CONF_DIR=/etc/apache2/conf-available
SERVICE_DIR=/etc/systemd/system
all: install
install: start_daemon
start_daemon: daemon
systemctl start $(NAME).service
daemon: rule web
@echo "Installing main daemon"
mkdir $(BINDIR)
cp src/$(NAME) $(BINDIR)/
cp src/scripts/* $(SCRIPTS_DIR)/
@echo "Installing configuration file"
mkdir /etc/$(NAME)
cp src/configuration.pl /etc/$(NAME)
@echo "Creating systemd service"
cp src/service/$(NAME).service $(SERVICE_DIR)/
@echo "Reloading systemd"
systemctl daemon-reload
rule:
@echo "Installing udev rule"
cp src/rules/$(RULE_NAME) $(RULES_DIR)
@echo "Restarting udev"
systemctl restart udev
web: clean-web web-conf-apache
@echo "Copying web files"
cp -r src/www/* $(WEB_PREFIX)/$(NAME)
web-conf-apache:
@echo "Copying apache configuration file"
cp src/apache/$(NAME).conf $(APACHE_CONF_DIR)/
@echo "Enabling apache configuration"
a2enconf $(NAME)
clean-web:
@echo "Removing old web installation"
rm -rf $(WEB_PREFIX)/$(NAME)
uninstall:
rm -rf $(WEB_PREFIX)/$(NAME) $(BINDIR)/$(NAME) $(RULES_DIR)/$(RULE_NAME)
# Tetras-back
Tetras-back is a free software designed to backup self hosting servers on
external hard drives.
## Requirements
To use Tetras-back, you need:
+ Systemd
+ Apache2 web server
## Install
just run `make install` from this directory
## Usage
### Manage discs
### Follow backup
### Set receiver address
### Add a backup script
## How does it works ?
### File hierarchy
/src/tetras-back Daemon script (perl)
/src/configuration.pl Configuration (perl)
/src/rules/50-tetras-back.rules Rule for USB drives
/src/scripts/* Backup scripts
/src/www/tetras-back Web page
/src/apache2/tetras-back.conf Apache2 configuration file
/src/service Systemd service
## Todo
+ [ ] Sendmail after backup or on fail
+ [ ] Daemon
+ [ ] Udev rules
+ [ ] Apache2 rule
+ [ ] Web interface
+ [ ] Disc Selection
+ [ ] Configuration file
## Licence
This program is distributed under GPLV3 Licence, see `Licence.txt`
#!/bin/bash
#
#-----------------------------------------------------------------------
#
# Script to backup all needed data upon USB hard disk insertion
# It is called thru UDEV with :
# - the device name (sda1, ...) given as the first parameter
#
#-----------------------------------------------------------------------
# Voir sur http://bernaerts.dyndns.org/linux/75-debian/54-debian-udev-backup
# Log beggining of backup
/usr/bin/logger Sauvegarde - démarrage le `date`
# if needed, create the mount directory
if [ ! -d /mnt/backup ] ; then mkdir /mnt/backup ; fi
# On rend la partition du disque USB visible
/bin/mount -t auto /dev/$1 /mnt/backup
# Sauvegarde du serveur lui-même
/usr/bin/logger Sauvegarde - Configuration /etc/
/usr/bin/rsync -rtv --modify-window=2 /etc/ /mnt/backup/etc
# On exclue le contenu des bibliothèques
/usr/bin/logger Sauvegarde - Configuration Seafile
/usr/bin/rsync -rtv --exclude 'seafile-data/storage' --modify-window=2 /srv/seafile.lesfeesrosses.org/ /mnt/backup/srv_seafile.lesfeesrosses.org/
# On sauvegarde le contenu des bibliothèques
/usr/bin/logger Sauvegarde - Contenu Seafile
if [ ! -d /mnt/seafile-fuse ] ; then mkdir /mnt/seafile-fuse ; fi
# Demonte le dossier si file au cas ou le dernier backup l'ait laisse dans un drole d'etat
fusermount -zu /mnt/seafile-fuse
/srv/seafile.lesfeesrosses.org/seafile-server-latest/seaf-fuse.sh start /mnt/seafile-fuse
/usr/bin/rsync -rtv --exclude 'seafile-data/storage' --modify-window=2 /mnt/seafile-fuse/ /mnt/backup/contenus_seafile/
# You can add here some other backups ...
#/usr/bin/logger Backup - other files
#/usr/bin/rsync -rtv --del --modify-window=2 /path/to/your/files/other /mnt/backup
# force sync of files to disk before unmounting
/bin/sync
# unmount the backup disk
/srv/seafile.lesfeesrosses.org/seafile-server-latest/seaf-fuse.sh stop
/bin/umount /mnt/backup
# Log end of backup
/usr/bin/logger Sauvegarde - terminée le `date`
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment