Skip to content

Instantly share code, notes, and snippets.

@sedrickcz
Created January 28, 2026 00:39
Show Gist options
  • Select an option

  • Save sedrickcz/a1b3c3588c0f15af63727b576d896ed2 to your computer and use it in GitHub Desktop.

Select an option

Save sedrickcz/a1b3c3588c0f15af63727b576d896ed2 to your computer and use it in GitHub Desktop.
Vaultwarden backup
#!/bin/bash
set -e
SRC="/home/sedrickcz/vaultwarden/data"
DEST="/mnt/reddwarf"
STAMP=$(date +%F)
TMP="/tmp/vaultwarden-$STAMP"
ARCHIVE="$DEST/vaultwarden-$STAMP.tgz"
mkdir -p "$TMP" "$DEST"
# Copy data to a temporary folder
rsync -a --delete "$SRC/" "$TMP/"
# Create a compressed archive on the NAS
tar czf "$ARCHIVE" -C "$TMP" .
# Remove the temporary folder
rm -rf "$TMP"
# Keep only the last 14 archives
find "$DEST" -name "vaultwarden-*.tgz" -mtime +14 -delete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment