progress
This commit is contained in:
Executable
+60
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env bash
|
||||
set -o pipefail
|
||||
|
||||
echo "*** START $0 ${*}"
|
||||
|
||||
# ------- Settings
|
||||
MAX_AGE_DAYS=1
|
||||
|
||||
SourceHost=hl-storage.cvtt.vpn
|
||||
SourceDir=/works/qcow2/shrunk
|
||||
|
||||
DownloadTgtDir=/opt/vm_drive/shrunk
|
||||
|
||||
# ------- Settings
|
||||
|
||||
download_latest() {
|
||||
local ssh_opts=(
|
||||
-o StrictHostKeyChecking=accept-new
|
||||
)
|
||||
|
||||
local rsync_rsh="ssh -o StrictHostKeyChecking=accept-new"
|
||||
|
||||
local FindCmd=(
|
||||
ssh
|
||||
"${ssh_opts[@]}"
|
||||
"$SourceHost"
|
||||
find "$SourceDir"
|
||||
-type f
|
||||
"-mtime -${MAX_AGE_DAYS}"
|
||||
"-printf '%P\0'"
|
||||
)
|
||||
|
||||
local RsyncCmd=(
|
||||
rsync
|
||||
-avh
|
||||
--progress
|
||||
--partial
|
||||
--append-verify
|
||||
-n
|
||||
--from0
|
||||
--files-from=-
|
||||
"-e $rsync_rsh"
|
||||
"${SourceHost}:${SourceDir}/"
|
||||
"${DownloadTgtDir}/"
|
||||
)
|
||||
|
||||
echo "-------------------"
|
||||
echo "Running:"
|
||||
set -x
|
||||
"${FindCmd[@]}" | "${RsyncCmd[@]}"
|
||||
{ set +x; } 2>/dev/null
|
||||
}
|
||||
|
||||
echo "-------------------"
|
||||
echo "Downloading files from ${SourceHost}:${SourceDir}"
|
||||
download_latest
|
||||
echo "-------------------"
|
||||
echo "Download completed"
|
||||
|
||||
echo "*** DONE: ${0} ${*}"
|
||||
Reference in New Issue
Block a user