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
install -m 755 sunt /usr/binExample config of ~/.config/sunt
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
cd /media/sdb1
sunt a file/file1 file2
sunt a -c file3Upload files to remote
sunt u file2 file3Delete files from index and on remote
sunt d -r file3Copy index file to remote
sunt iAdd and upload files
sunt au file4 file5
sunt au -c file6/*.mp4Restore files from remote
sunt r file3
sunt r -f file2Show index file
sunt lHere's a command wrapper for .bashrc that when called with no arguments spawns fzf selection to restore files
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
}