Skip to content

Commit

Permalink
rsync: Make --delete-excluded an option
Browse files Browse the repository at this point in the history
  • Loading branch information
taoky committed Dec 28, 2024
1 parent 67d2903 commit 78ab293
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
35 changes: 18 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -387,23 +387,24 @@ ref:
[![rsync](https://img.shields.io/docker/image-size/ustcmirror/rsync/latest)](https://hub.docker.com/r/ustcmirror/rsync "rsync")
[![rsync](https://img.shields.io/docker/pulls/ustcmirror/rsync)](https://hub.docker.com/r/ustcmirror/rsync "rsync")

| Parameter | Description |
| --------------------- | ---------------------------------------------------------------- |
| `RSYNC_HOST` | The hostname of the remote server. |
| `RSYNC_USER` | (Optional) No defaults. |
| `RSYNC_PASSWORD` | (Optional) No defaults. |
| `RSYNC_PATH` | The destination path on the remote server. |
| `RSYNC_BW` | Bandwidth limit. Defaults to `0`. |
| `RSYNC_EXTRA` | Extra options. Defaults to empty. |
| `RSYNC_EXCLUDE` | Files to be excluded. Defaults to `--exclude .~tmp~/`. |
| `RSYNC_FILTER` | Filter rules. More convenient for larger lists. |
| `RSYNC_BLKSIZE` | Defaults to `8192`. |
| `RSYNC_TIMEOUT` | Defaults to `14400`. |
| `RSYNC_SPARSE` | Defaults to `true`. |
| `RSYNC_DELAY_UPDATES` | Defaults to `true`. |
| `RSYNC_DELETE_DELAY` | Defaults to `true`. Use `--delete-delay` rather than `--delete` |
| `RSYNC_MAXDELETE` | Maximum number of files that can be removed. Defaults to `4000`. |
| `RSYNC_RSH` | Specify the remote shell, e.g. `ssh -i /path/to/key`. |
| Parameter | Description |
| ---------------------- | --------------------------------------------------------------------- |
| `RSYNC_HOST` | The hostname of the remote server. |
| `RSYNC_USER` | (Optional) No defaults. |
| `RSYNC_PASSWORD` | (Optional) No defaults. |
| `RSYNC_PATH` | The destination path on the remote server. |
| `RSYNC_BW` | Bandwidth limit. Defaults to `0`. |
| `RSYNC_EXTRA` | Extra options. Defaults to empty. |
| `RSYNC_EXCLUDE` | Files to be excluded. Defaults to `--exclude .~tmp~/`. |
| `RSYNC_FILTER` | Filter rules. More convenient for larger lists. |
| `RSYNC_BLKSIZE` | Defaults to `8192`. |
| `RSYNC_TIMEOUT` | Defaults to `14400`. |
| `RSYNC_SPARSE` | Defaults to `true`. |
| `RSYNC_DELAY_UPDATES` | Defaults to `true`. |
| `RSYNC_DELETE_DELAY` | Defaults to `true`. Use `--delete-delay` rather than `--delete` |
| `RSYNC_DELETE_EXCLUDED`| Defaults to `true`. Use `--delete-excluded` to delete excluded files. |
| `RSYNC_MAXDELETE` | Maximum number of files that can be removed. Defaults to `4000`. |
| `RSYNC_RSH` | Specify the remote shell, e.g. `ssh -i /path/to/key`. |

### rubygems

Expand Down
4 changes: 3 additions & 1 deletion rsync/sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ RSYNC_RSH=${RSYNC_RSH:-''}
RSYNC_DELAY_UPDATES="${RSYNC_DELAY_UPDATES:-true}"
RSYNC_SPARSE="${RSYNC_SPARSE:-true}"
RSYNC_DELETE_DELAY="${RSYNC_DELETE_DELAY:-true}"
RSYNC_DELETE_EXCLUDED="${RSYNC_DELETE_EXCLUDED:-true}"

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

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

[[ $RSYNC_DELETE_EXCLUDED = true ]] && opts+=' --delete-excluded'
[[ $RSYNC_DELETE_DELAY = true ]] && opts+=' --delete-delay' || opts+=' --delete'
[[ $RSYNC_DELAY_UPDATES = true ]] && opts+=' --delay-updates'
[[ $RSYNC_SPARSE = true ]] && opts+=' --sparse'
Expand Down

0 comments on commit 78ab293

Please sign in to comment.