diff options
| author | Your Name <you@example.com> | 2026-02-20 23:03:46 +0800 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-02-20 23:03:46 +0800 |
| commit | 59873118094ef8238ba73b7720493dd855cf7af8 (patch) | |
| tree | 5416cab2c7c45843282d04368a0899b985ba6e7e /backup.sh | |
| parent | be5699a8da55d30fa309743a03a8aca2d1662403 (diff) | |
hehe
Diffstat (limited to 'backup.sh')
| -rwxr-xr-x | backup.sh | 24 |
1 files changed, 0 insertions, 24 deletions
diff --git a/backup.sh b/backup.sh deleted file mode 100755 index 6e54e8e..0000000 --- a/backup.sh +++ /dev/null | |||
| @@ -1,24 +0,0 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | set -e | ||
| 3 | |||
| 4 | [ $# -ne 3 ] && echo "Usage: $0 <dir-to-backup> <tarfile-name> <user@host:/remote/dir>" && exit 1 | ||
| 5 | |||
| 6 | SRC="$1" | ||
| 7 | NAME="$2" | ||
| 8 | DEST="$3" | ||
| 9 | |||
| 10 | [ ! -d "$SRC" ] && echo "Error: '$SRC' is not a directory" && exit 1 | ||
| 11 | |||
| 12 | TARFILE="$(pwd)/${NAME}.tar.gz" | ||
| 13 | |||
| 14 | echo "Compressing $SRC → $TARFILE" | ||
| 15 | tar -czf "$TARFILE" -C "$(dirname "$SRC")" "$(basename "$SRC")" | ||
| 16 | |||
| 17 | SIZE=$(du -h "$TARFILE" | cut -f1) | ||
| 18 | echo "Size: $SIZE" | ||
| 19 | |||
| 20 | echo "Sending to $DEST" | ||
| 21 | rsync -avP "$TARFILE" "$DEST/" | ||
| 22 | |||
| 23 | rm -f "$TARFILE" | ||
| 24 | echo "Done" | ||
