From e54d77678823f0b17743e56eee79feb80dd8b384 Mon Sep 17 00:00:00 2001 From: clyhtsuriva Date: Wed, 2 Aug 2023 10:31:50 +0200 Subject: Add remote backup functionality --- bin/backup-usb32.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'bin/backup-usb32.sh') diff --git a/bin/backup-usb32.sh b/bin/backup-usb32.sh index 6dd038f..3a0002e 100755 --- a/bin/backup-usb32.sh +++ b/bin/backup-usb32.sh @@ -1,8 +1,24 @@ #!/usr/bin/env bash -rsync -az -u -v /mnt/32 ~/Documents/32.bak/ +if [ "$#" -ne 6 ]; then + echo "Usage: $0 " + exit 1 +fi + +source_directory="$1" +local_destination_directory="$2" +remote_destination_directory="$3" +username="$4" +server_address="$5" +ssh_port="$6" + +# Backup USB key to local machine +rsync -az -u -v "$source_directory" "$local_destination_directory" # --archive, -a archive mode is -rlptgoD (no -A,-X,-U,-N,-H) # --compress, -z compress file data during the transfer # --update, -u skip files that are newer on the receiver # --verbose, -v increase verbosity + +# Backup USB key to server over SSH using the provided port +rsync -az -u -v -e "ssh -p $ssh_port" "$source_directory" "$username"@"$server_address":"$remote_destination_directory" -- cgit v1.2.3