Compare commits

...

5 Commits

Author SHA1 Message Date
14ac2d9763 Prune old archives 2024-08-13 10:41:13 +02:00
36798f9cf4 Update README 2024-08-10 00:01:38 +02:00
f3a49945aa Update README: correct naming scheme of .deb 2024-08-09 13:47:11 +02:00
147df3c3a6 Add 'initialize' command, define 'backup' command 2024-08-09 13:46:40 +02:00
b0df927e75 Fix: correctly check required arguments 2024-08-09 09:54:54 +02:00
4 changed files with 22 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
Package: tupper Package: tupper
Version: 0.1 Version: 0.1.1
Maintainer: Martin "maride" Dessauer Maintainer: Martin "maride" Dessauer
Architecture: all Architecture: all
Depends: cron (>= 3.0), borgbackup (<< 2), sshfs (>= 3) Depends: cron (>= 3.0), borgbackup (<< 2), sshfs (>= 3)

View File

@@ -8,20 +8,20 @@ Drops of glue between [SSHFS](https://github.com/libfuse/sshfs), [Borg](https://
- Encrypted, deduplicated backups thanks to Borg - Encrypted, deduplicated backups thanks to Borg
- Backup of specified directories to SSHFS - Backup of specified directories to SSHFS
- Daily cron scheduler - Daily cron scheduler
- Auto-prune old archives
## Usage ## Usage
Enter SSH credentials, host and destination directory in `/etc/tupper.conf`, as well as the directories to back up. Enter SSH credentials, host and destination directory in `/etc/tupper.conf`, as well as the directories to back up.
After that, run `sudo tupper initialize` once to init the Borg repository.
Then either run `sudo tupper` or wait for the daily cron scheduler to kick in. Then either run `sudo tupper backup` or wait for the daily cron scheduler to kick in.
## Building ## Building
`dpkg-deb --build . tupper_0.1_any.deb` `dpkg-deb --build . tupper_0.1.1_all.deb`
## TODO / Known pitfalls ## TODO / Known pitfalls
- The Borg backup destination (thus, the contents of the SSHFS directory) must be `borg init`ed; tupper won't do that (and probably shouldn't anyway)
- If `tupper` fails with `timeout waiting for prompt`, you may need to validate and accept the SSH host key: `ssh-keyscan yournas.local | sudo tee --append /root/.ssh/known_hosts` - If `tupper` fails with `timeout waiting for prompt`, you may need to validate and accept the SSH host key: `ssh-keyscan yournas.local | sudo tee --append /root/.ssh/known_hosts`

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash
/usr/sbin/tupper 2>&1 | tee --append /var/log/tupper.log /usr/sbin/tupper backup 2>&1 | tee --append /var/log/tupper.log

View File

@@ -3,6 +3,14 @@
# Inform user # Inform user
echo "Welcome to tupper! Running on $(date)" echo "Welcome to tupper! Running on $(date)"
# Check if it is clear what to do
ACTION="$1"
if [ "$ACTION" != "backup" ] && [ "$ACTION" != "initialize" ]; then
echo "tupper requires an action: $0 { initialize | backup }" 1>&2
echo "Unrecognized action: $ACTION" 1>&2
exit 1
fi
# Check access rights of config file # Check access rights of config file
CONF="/etc/tupper.conf" CONF="/etc/tupper.conf"
if [ "$(stat -c '%U' $CONF)" != "root" ] && [ "$(stat -c '%A' $CONF)" = "*------" ]; then if [ "$(stat -c '%U' $CONF)" != "root" ] && [ "$(stat -c '%A' $CONF)" = "*------" ]; then
@@ -13,7 +21,7 @@ fi
source "$CONF" source "$CONF"
# Check if required variables are set # Check if required variables are set
if [ "$SSH_URI$SSH_PASS$TARGET" = "" ]; then if [ "$SSH_URI" = "" ] || [ "$SSH_PASS" = "" ] || [ "$TARGET" = "" ]; then
echo "Config file $CONF must contain SSH_URI, SSH_PASS and TARGET" 1>&2 echo "Config file $CONF must contain SSH_URI, SSH_PASS and TARGET" 1>&2
exit 1 exit 1
fi fi
@@ -35,8 +43,13 @@ fi
# Backup # Backup
export BORG_PASSPHRASE export BORG_PASSPHRASE
export BORG_RELOCATED_REPO_ACCESS_IS_OK=yes export BORG_RELOCATED_REPO_ACCESS_IS_OK=yes
borg create --stats "$MOUNTPOINT::"'{now}' "$TARGET" if [ "$ACTION" = "initialize" ]; then
borg list "$MOUNTPOINT" borg init --encryption=repokey "$TARGET"
elif [ "$ACTION" = "backup" ]; then
borg create --stats "$MOUNTPOINT::"'{now}' "$TARGET"
borg prune --list --show-rc --keep-daily 7 --keep-weekly 4 --keep-monthly 3 "$MOUNTPOINT"
borg list "$MOUNTPOINT"
fi
# Unmount and clean up mountpoint # Unmount and clean up mountpoint
fusermount -u "$MOUNTPOINT" && \ fusermount -u "$MOUNTPOINT" && \