Created
January 28, 2026 00:39
-
-
Save sedrickcz/a1b3c3588c0f15af63727b576d896ed2 to your computer and use it in GitHub Desktop.
Vaultwarden backup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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