Init
This commit is contained in:
commit
6ef597701f
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
*.deb
|
1
DEBIAN/conffiles
Normal file
1
DEBIAN/conffiles
Normal file
@ -0,0 +1 @@
|
||||
/etc/tupper.conf
|
6
DEBIAN/control
Normal file
6
DEBIAN/control
Normal file
@ -0,0 +1,6 @@
|
||||
Package: tupper
|
||||
Version: 0.1
|
||||
Maintainer: Martin "maride" Dessauer
|
||||
Architecture: all
|
||||
Depends: cron (>= 3.0), borgbackup (<< 2), sshfs (>= 3)
|
||||
Description: Some drops of glue between SSHFS, Borg and cron
|
10
DEBIAN/postinst
Executable file
10
DEBIAN/postinst
Executable file
@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "$1" == "configure" ]; then
|
||||
chown root:root /etc/tupper.conf
|
||||
chmod 600 /etc/tupper.conf
|
||||
chown root:root /etc/cron.daily/tupper
|
||||
chmod 755 /etc/cron.daily/tupper
|
||||
chown root:root /usr/sbin/tupper
|
||||
chmod 755 /usr/sbin/tupper
|
||||
fi
|
0
DEBIAN/postrm
Executable file
0
DEBIAN/postrm
Executable file
0
DEBIAN/preinst
Executable file
0
DEBIAN/preinst
Executable file
0
DEBIAN/prerm
Executable file
0
DEBIAN/prerm
Executable file
21
README.md
Normal file
21
README.md
Normal file
@ -0,0 +1,21 @@
|
||||
# tupper
|
||||
|
||||
Drops of glue between [SSHFS](https://github.com/libfuse/sshfs), [Borg](https://www.borgbackup.org/) and [cron](https://github.com/vixie/cron)
|
||||
|
||||
## Features
|
||||
|
||||
- Auto-mounts specified SSHFS as required
|
||||
- Encrypted, deduplicated backups thanks to Borg
|
||||
- Backup of specified directories to SSHFS
|
||||
- Daily cron scheduler
|
||||
|
||||
## Usage
|
||||
|
||||
Enter SSH credentials, host and destination directory in `/etc/tupper.conf`, as well as the directories to back up.
|
||||
|
||||
Then either run `sudo tupper` or wait for the daily cron scheduler to kick in.
|
||||
|
||||
## Building
|
||||
|
||||
`dpkg-deb --build . tupper_0.1_any.deb`
|
||||
|
4
etc/cron.daily/tupper
Executable file
4
etc/cron.daily/tupper
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
/usr/sbin/tupper 2>&1 | tee --append /var/log/tupper.log
|
||||
|
8
etc/tupper.conf
Normal file
8
etc/tupper.conf
Normal file
@ -0,0 +1,8 @@
|
||||
### tupper.conf - config file for tupper
|
||||
#
|
||||
## Example:
|
||||
# SSH_URI='backupuser@yournas.local:/filez'
|
||||
# SSH_PASS='p4$$w0rcl'
|
||||
# BORG_PASSPHRASE='backuppass'
|
||||
# TARGET='/var/lib/docker/volumes'
|
||||
|
45
usr/sbin/tupper
Executable file
45
usr/sbin/tupper
Executable file
@ -0,0 +1,45 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
# Inform user
|
||||
echo "Welcome to tupper! Running on $(date)"
|
||||
|
||||
# Check access rights of config file
|
||||
CONF="/etc/tupper.conf"
|
||||
if [ "$(stat -c '%U' $CONF)" != "root" ] && [ "$(stat -c '%A' $CONF)" = "*------" ]; then
|
||||
echo "Config file $CONF must be owned by root without any rights for group and other (**00) set" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
# Include config file
|
||||
source "$CONF"
|
||||
|
||||
# Check if required variables are set
|
||||
if [ "$SSH_URI$SSH_PASS$TARGET" = "" ]; then
|
||||
echo "Config file $CONF must contain SSH_URI, SSH_PASS and TARGET" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check privileges
|
||||
if [ "$UID" -ne 0 ]; then
|
||||
echo "$0 must be run as root. Quitting." 1>2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create temporary mountpoint
|
||||
MOUNTPOINT="$(mktemp --directory)"
|
||||
|
||||
# Check if SSHFS needs to be mounted
|
||||
if [ "$(mount | grep $MOUNTPOINT | wc -l)" -eq 0 ]; then
|
||||
echo "$SSH_PASS" | sshfs -o password_stdin "$SSH_URI" "$MOUNTPOINT"
|
||||
fi
|
||||
|
||||
# Backup
|
||||
export BORG_PASSPHRASE
|
||||
borg create --stats "$MOUNTPOINT::"'{now}' "$TARGET"
|
||||
borg list "$MOUNTPOINT"
|
||||
|
||||
# Unmount and clean up mountpoint
|
||||
fusermount -u "$MOUNTPOINT" && \
|
||||
rm -rf "$MOUNTPOINT"
|
||||
|
||||
# Inform user
|
||||
echo "Goodbye from tupper! Finished on $(date)"
|
Loading…
Reference in New Issue
Block a user