aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorclyhtsuriva <aimeric@adjutor.xyz>2023-08-02 10:31:50 +0200
committerclyhtsuriva <aimeric@adjutor.xyz>2023-08-02 10:31:50 +0200
commite54d77678823f0b17743e56eee79feb80dd8b384 (patch)
treea05c63840aba04f06d32a6fa531be5e7d59d370a
parentdab214b31a4aeb9f16806c6215da334c23634bc8 (diff)
Add remote backup functionality
-rwxr-xr-xbin/backup-usb32.sh18
1 files changed, 17 insertions, 1 deletions
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 <source_directory> <local_destination_directory> <remote_destination_directory> <username> <server_address> <ssh_port>"
+ 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"