Skip to content

Commit 0f952a2

Browse files
committed
Improve Rsync scripts (Thanks kevors)
Improve Rsync scripts (Thanks kevors) Signed-off-by: Bensuperpc <[email protected]>
1 parent b108b31 commit 0f952a2

File tree

3 files changed

+64
-8
lines changed

3 files changed

+64
-8
lines changed

file/rsync/rsync-archive.sh

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ set -euo pipefail
1111
#// //
1212
#// Script, 2020 //
1313
#// Created: 21, November, 2020 //
14-
#// Modified: 24, July, 2021 //
14+
#// Modified: 03, August, 2021 //
1515
#// file: - //
1616
#// - //
1717
#// Source: - //
@@ -21,7 +21,25 @@ set -euo pipefail
2121
#//////////////////////////////////////////////////////////////
2222

2323
if (( $# == 2 )); then
24-
rsync --progress --stats --archive --xattrs --acls --partial --delete-during --verbose --human-readable --log-file=log_rsync_"$(date +%Y-%m-%d_%H_%M_%S)".log "$1" "$2"
24+
LOG_DATE=$(date +%Y-%m-%d_%H_%M_%S)
25+
26+
rsync --progress --stats --archive --xattrs --acls --dry-run \
27+
--delete-during --human-readable --partial "$1" "$2"
28+
29+
echo
30+
echo "Warning! In '$2' some files will be deleted."
31+
read -p "Are you sure ? [Y/n]" -n 1 -r
32+
echo
33+
34+
if [[ $REPLY =~ ^[Y]$ ]]; then
35+
echo "Sync in 5 seconds..."
36+
sleep 5
37+
rsync --progress --stats --archive --acls --partial \
38+
--delete-during --human-readable --xattrs \
39+
--log-file=log_rsync_"$LOG_DATE".log "$1" "$2"
40+
else
41+
echo "No sync"
42+
fi
2543
else
2644
echo "Usage: ${0##*/} <source> <destination>"
2745
exit 1

file/rsync/rsync-check.sh

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ set -euo pipefail
1111
#// //
1212
#// Script, 2020 //
1313
#// Created: 21, November, 2020 //
14-
#// Modified: 24, July, 2021 //
14+
#// Modified: 03, August, 2021 //
1515
#// file: - //
1616
#// - //
1717
#// Source: - //
@@ -21,7 +21,25 @@ set -euo pipefail
2121
#//////////////////////////////////////////////////////////////
2222

2323
if (( $# == 2 )); then
24-
rsync --progress --stats --archive --xattrs --acls --partial --checksum --delete-during --verbose --human-readable --log-file=log_rsync_"$(date +%Y-%m-%d_%H_%M_%S)".log "$1" "$2"
24+
LOG_DATE=$(date +%Y-%m-%d_%H_%M_%S)
25+
26+
rsync --progress --stats --archive --xattrs --acls --dry-run \
27+
--delete-during --human-readable --partial --checksum "$1" "$2"
28+
29+
echo
30+
echo "Warning! In '$2' some files will be deleted."
31+
read -p "Are you sure ? [Y/n]" -n 1 -r
32+
echo
33+
34+
if [[ $REPLY =~ ^[Y]$ ]]; then
35+
echo "Sync in 5 seconds..."
36+
sleep 5
37+
rsync --progress --stats --archive --xattrs --acls --partial \
38+
--delete-during --human-readable --checksum \
39+
--log-file=log_rsync_"$LOG_DATE".log "$1" "$2"
40+
else
41+
echo "No sync"
42+
fi
2543
else
2644
echo "Usage: ${0##*/} <source> <destination>"
2745
exit 1

file/rsync/rsync-rsa.sh

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ set -euo pipefail
99
#// |_| |_| //
1010
#//////////////////////////////////////////////////////////////
1111
#// //
12-
#// Script, 2021 //
13-
#// Created: 27, May, 2021 //
14-
#// Modified: 24, July, 2021 //
12+
#// Script, 2020 //
13+
#// Created: 21, November, 2020 //
14+
#// Modified: 03, August, 2021 //
1515
#// file: - //
1616
#// - //
1717
#// Source: - //
@@ -21,7 +21,27 @@ set -euo pipefail
2121
#//////////////////////////////////////////////////////////////
2222

2323
if (( $# == 4 )); then
24-
rsync --progress --compress --stats --archive --xattrs --acls --partial --delete-during --verbose --human-readable -e "ssh -p $1 -i $2 -o IdentitiesOnly=true" --log-file=log_rsync_"$(date +%Y-%m-%d_%H_%M_%S)".log "$3" "$4"
24+
LOG_DATE=$(date +%Y-%m-%d_%H_%M_%S)
25+
26+
rsync --progress --stats --archive --xattrs --acls --partial \
27+
--delete-during --human-readable --dry-run \
28+
-e "ssh -p $1 -i $2 -o IdentitiesOnly=true" "$3" "$4"
29+
30+
echo
31+
echo "Warning! In '$4' some files will be deleted."
32+
read -p "Are you sure ? [Y/n]" -n 1 -r
33+
echo
34+
35+
if [[ $REPLY =~ ^[Y]$ ]]; then
36+
echo "Sync in 5 seconds..."
37+
sleep 5
38+
rsync --progress --stats --archive --xattrs --acls --partial \
39+
--delete-during --human-readable \
40+
--log-file=log_rsync_"$LOG_DATE".log \
41+
-e "ssh -p $1 -i $2 -o IdentitiesOnly=true" "$3" "$4"
42+
else
43+
echo "No sync"
44+
fi
2545
else
2646
echo "Usage: ${0##*/} <port> <key-file> <source> <destination>"
2747
exit 1

0 commit comments

Comments
 (0)