https://github.com/tuvimen/sunt
A bash script for backing up files
https://github.com/tuvimen/sunt
backup bash
Last synced: about 2 months ago
JSON representation
A bash script for backing up files
- Host: GitHub
- URL: https://github.com/tuvimen/sunt
- Owner: TUVIMEN
- License: gpl-3.0
- Created: 2022-05-23T06:56:28.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2025-06-04T17:11:35.000Z (about 1 year ago)
- Last Synced: 2025-06-04T22:37:34.368Z (about 1 year ago)
- Topics: backup, bash
- Language: Shell
- Homepage:
- Size: 34.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sunt
A bash script for backing up files.
My reasoning behind this project: https://tuvimen.neocities.org/posts/secure-and-quick-backup-of-huge-amount-of-files-via-ssh
## Installation
```bash
install -m 755 sunt /usr/bin
```
## Usage
Example config of `~/.config/sunt`
```bash
SUNT_INDEX="/home/user3/index"
SUNT_ENCRYPT="openssl enc -e -aes-256-cbc -salt -pbkdf2 -iter 1000000 -md sha512 -in /dev/stdin -pass file/home/user3/pass -out /dev/stdout"
SUNT_DECRYPT="openssl enc -d -aes-256-cbc -salt -pbkdf2 -iter 1000000 -md sha512 -in /dev/stdin -pass file:/ome/user3/pass -out /dev/stdout"
SUNT_COMPRESS="xz -e9"
SUNT_DECOMPRESS="unxz"
SUNT_HASH="sha256sum"
SUNT_DEST="user1,ssh user1@192.168.1.104,/media/sdc1,/home/user3/d1,user2,ssh user2@192.168.1.105,/media/sdc2,/home/user3/d2"
```
Add files to index
```bash
cd /media/sdb1
sunt a file/file1 file2
sunt a -c file3
```
Upload files to remote
```bash
sunt u file2 file3
```
Delete files from index and on remote
```bash
sunt d -r file3
```
Copy index file to remote
```bash
sunt i
```
Add and upload files
```bash
sunt au file4 file5
sunt au -c file6/*.mp4
```
Restore files from remote
```bash
sunt r file3
sunt r -f file2
```
Show index file
```bash
sunt l
```
## Wrapper
Here's a command wrapper for `.bashrc` that when called with no arguments spawns `fzf` selection to restore files
```bash
sunt() {
if [ "$#" -eq 0 ]
then
. ~/.config/sunt
local destination path sel
mapfile -t -d, destination <<< "$SUNT_DEST"
[ "$((${#destination[@]}%4))" -ne '0' ] && {
echo "invalid SUNT_DEST" >&2
exit 1
}
path="${destination[3]//$'\n'}"
sel="$(cut -f2 "$SUNT_INDEX" | fzf -i --multi)"
[ -z "$sel" ] && return
local IFS=$'\n'
command sunt r $(sed "s#^#$path/#" <<< "$sel")
else
command sunt "$@"
fi
}
```