Skip to content

Commit 0cdbb0b

Browse files
committed
rsync: Add RSYNC_NO_DELETE
1 parent 314a350 commit 0cdbb0b

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,7 @@ ref:
422422
| `RSYNC_DELETE_EXCLUDED`| Defaults to `true`. Use `--delete-excluded` to delete excluded files. |
423423
| `RSYNC_MAXDELETE` | Maximum number of files that can be removed. Defaults to `4000`. |
424424
| `RSYNC_RSH` | Specify the remote shell, e.g. `ssh -i /path/to/key`. |
425+
| `RSYNC_NO_DELETE` | Defaults to `false`. Set to `true` to disable all deletion arguments. |
425426

426427
### rubygems / rubygems-dynamic
427428

rsync/sync.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@ RSYNC_DELAY_UPDATES="${RSYNC_DELAY_UPDATES:-true}"
2323
RSYNC_SPARSE="${RSYNC_SPARSE:-true}"
2424
RSYNC_DELETE_DELAY="${RSYNC_DELETE_DELAY:-true}"
2525
RSYNC_DELETE_EXCLUDED="${RSYNC_DELETE_EXCLUDED:-true}"
26+
RSYNC_NO_DELETE="${RSYNC_NO_DELETE:-false}"
2627

2728
opts="-pPrltvH --partial-dir=.rsync-partial --timeout ${RSYNC_TIMEOUT} --safe-links"
2829

2930
[[ -n $RSYNC_USER ]] && RSYNC_HOST="$RSYNC_USER@$RSYNC_HOST"
3031

31-
[[ $RSYNC_DELETE_EXCLUDED = true ]] && opts+=' --delete-excluded'
32-
[[ $RSYNC_DELETE_DELAY = true ]] && opts+=' --delete-delay' || opts+=' --delete'
32+
if [[ $RSYNC_NO_DELETE != true ]]; then
33+
[[ $RSYNC_DELETE_EXCLUDED = true ]] && opts+=' --delete-excluded'
34+
[[ $RSYNC_DELETE_DELAY = true ]] && opts+=' --delete-delay' || opts+=' --delete'
35+
fi
3336
[[ $RSYNC_DELAY_UPDATES = true ]] && opts+=' --delay-updates'
3437
[[ $RSYNC_SPARSE = true ]] && opts+=' --sparse'
3538
[[ $RSYNC_BLKSIZE -ne 0 ]] && opts+=" --block-size ${RSYNC_BLKSIZE}"
@@ -54,4 +57,7 @@ else
5457
RSYNC_URL="rsync://$RSYNC_HOST/$RSYNC_PATH"
5558
fi
5659

57-
exec rsync $RSYNC_EXCLUDE --filter="merge $filter_file" --bwlimit "$RSYNC_BW" --max-delete "$RSYNC_MAXDELETE" $opts $RSYNC_EXTRA "$RSYNC_URL" "$TO"
60+
max_delete_arg="--max-delete $RSYNC_MAXDELETE"
61+
[[ $RSYNC_NO_DELETE = true ]] && max_delete_arg=''
62+
63+
exec rsync $RSYNC_EXCLUDE --filter="merge $filter_file" --bwlimit "$RSYNC_BW" $max_delete_arg $opts $RSYNC_EXTRA "$RSYNC_URL" "$TO"

0 commit comments

Comments
 (0)